<template>
  <div style="overflow:auto;height: 480px;">

    <vxe-grid
        size="mini"
        ref="xTable"
        v-bind="gridOptions"
        height="400px"
        @cell-dblclick="handleDetails"
        @cell-click="handleClick"
        @radio-change="currentChangeEvent"
        @custom="toolbarCustomEvent"
        @checkbox-change="selectPersonnel"
        @checkbox-all="allSelectPersonnel"
        :loading="VxeLoading"
    >
      <template #toolbar_buttons>
        <div class="select_search">
          <div style="min-width: 850px;overflow-x: auto">
            <we-button @click="refreshData" type="primary" size="small"
            ><em class="el-icon-refresh"></em> 刷新
            </we-button>

            <we-button @click="add" type="primary" size="small"
            ><em class="el-icon-plus"></em> 添加
            </we-button>

            <we-button @click="handleDetails({})" type="primary" size="small"
            ><em class="el-icon-edit"></em> 编辑
            </we-button>
            <we-button @click="handleDelete" type="primary" size="small"
            ><em class="el-icon-edit"></em> 删除
            </we-button>
            <!-- <we-button @click="showQuery = true" type="primary" size="small"
            ><em class="el-icon-search"></em> 常用条件查询
            </we-button> -->
            <we-button @click="imgBtn" type="primary" size="small"
            ><em class="el-icon-picture-outline"></em> 显示照片
            </we-button>
            <we-button @click="noPhoto" type="primary" size="small"
            ><em class="el-icon-picture-outline"></em> 无照片
            </we-button>
            <we-button @click="showSort" type="primary" size="small"
            ><em class="el-icon-picture-outline"></em> 集体内排序
            </we-button>
            <we-button @click="showCommonAnalyse" type="primary" size="small"
            ><em class="el-icon-picture-outline"></em> 常用统计分析
            </we-button>
            <we-button @click="showCustomAnalyse" type="primary" size="small"
            ><em class="el-icon-picture-outline"></em> 自定义统计分析
            </we-button>
            <we-button @click="intelligence = true" type="primary" size="small"
            ><em class="el-icon-picture-outline"></em> 智能导入
            </we-button>
          </div>
          <div>
            <el-select
                v-model="updateStatus"
                @change="updatePersonnelStatus"
                size="mini"
                @visible-change="resetPersonnelStatus"
                placeholder="移动"
                style="width: 120px"
            >
              <el-option
                  v-for="(item,index) in PersonnelStatus"
                  :key="index"
                  :label="item.itemText"
                  :value="item.uuid"
                  :disabled="item.disabled"
              >
              </el-option>
            </el-select>
            <el-cascader
              v-model="batchValue"
              @change="batchProcessing"
              :options="batchOperation"
              size="mini"
              style="width: 120px; margin-left: 10px"
            />
          </div>
        </div>
      </template>
      <!-- <template #operate="{ row }">
        <we-button style="line-height:0" size="mini" type="primary" @click="handleDetails(row)"
          ><em class="el-icon-caret-right" />编辑</we-button
        >
        <el-popconfirm title="确定删除吗？" @confirm="handleDelete(row.uuid)">
          <we-button style="line-height:0" slot="reference" size="mini" type="danger">删除</we-button>
        </el-popconfirm>
      </template> -->
      <template #operated="{ row }">
        <div v-show="selectRow.uuid == row.uuid">
          <div class="text-center">{{ row.name }}</div>
          <el-image
              style="width: 90px; height: 110px"
              :src="showImg"
              :preview-src-list="[showImg]"
          ></el-image>
          <div class="text-center">
            <we-button size="mini" type="primary" @click="editImg">编辑</we-button>
          </div>
        </div>
      </template>
    </vxe-grid>
    <el-dialog
        :title="eitPhotoTitle"
        :visible.sync="eitPhoto"
        :close-on-press-escape="false"
        :close-on-click-modal="false"
        :before-close="handleCloseDialog"
        width="30%"
    >
      <el-upload
          class="avatar-uploader"
          :action="picUrl"
          :show-file-list="false"
          :on-success="handleAvatarSuccess"
          :before-upload="beforeAvatarUpload"
      >
        <div style="width: 108px;height: 108px;position: relative">
          <img v-if="imageUrl" :src="imageUrl" class="avatar" alt="头像"/>
          <em v-else class="el-icon-plus avatar-uploader-icon"></em>
        </div>
      </el-upload>
      <span slot="footer" class="dialog-footer">
      <el-button size="mini" @click="handleUpPhoto">上传</el-button>
      <el-button size="mini" @click="handleCloseDialog">关闭</el-button>
    </span>
    </el-dialog>
    <div class="table_tools">
      <we-pagination
          :total="pagerConfig.total"
          @currentChange="currentChange"
      ></we-pagination>
    </div>
    <personnel-base-modal
        v-if="showModal"
        :row="clickRow"
        :isEit="isEit"
        :show="showModal"
        @upData="upData"
        @changeShowModal="changeShowModal"
    ></personnel-base-modal>

    <el-dialog
        title="请选择要操作的子集"
        :visible.sync="centerDialogVisible"
        :close-on-click-modal="false"
        :close-on-press-escape="false"
        :show-close="false"

        class="el-dialog-subset"
        center
    >
      <el-select
          v-if="!isDeleteSubset"
          v-model="selectSubset"
          filterable
          size="mini"
          style="width: 100%; padding: 0 100px"
      >
        <el-option
            v-for="(item,index) in allSubset"
            :key="index"
            :label="item.tableTxt"
            :value="item.tableName"
        >
        </el-option>
      </el-select>
      <div v-if="isDeleteSubset">
        <el-checkbox
            :indeterminate="isIndeterminate"
            v-model="checkAll"
            @change="handleCheckAllChange"
        >全选
        </el-checkbox
        >
        <div style="margin: 15px 0"></div>
        <el-checkbox-group
            v-model="checkedDelete"
            @change="handleCheckedCitiesChange"
        >
          <el-checkbox
              style="display: block"
              v-for="item in deleteSubset"
              :label="item"
              :key="item"
          >{{ item }}
          </el-checkbox
          >
        </el-checkbox-group>
      </div>

      <span slot="footer" class="dialog-footer">
        <we-button size="small" @click="subsetBtnF">关 闭</we-button>
        <we-button size="small" type="primary" @click="subsetBtnT"
        >确 定</we-button
        >
      </span>
    </el-dialog>
    <el-dialog
        title="集体内排序"
        :visible.sync="sortModal"
        show-close
        custom-class="custom-dialog"
    >
      <div style="display: flex; justify-content: space-around">
        <div
            style="
            border: 1px solid #cdcdcd;
            padding: 20px;
            width: 300px;
            border-radius: 5px;
          "
        >
          <el-tree
              class="department-tree"
              :data="allGroupList"
              :props="defaultProps"
              ref="tree"
              style="height: 360px;overflow-y: auto"
          >
          </el-tree>
        </div>
        <div
            style="
            border: 1px solid #cdcdcd;
            padding: 20px;
            width: 300px;
            border-radius: 5px;
          "
        >
          <draggable
              v-model="gridOptions.data"
              group="site"
              animation="300"
              dragClass="dragClass"
              ghostClass="ghostClass"
              chosenClass="chosenClass"
              @start="onStart"
              @end="onEnd"
          >
            <transition-group>
              <div
                  class="item"
                  v-for="item in gridOptions.data"
                  :key="item.uuid"
              >
                {{ item.name }}
              </div>
            </transition-group>
          </draggable>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <we-button @click="sortModal = false" type="primary" size="small"
        ><em class="el-icon-search"></em> 取 消</we-button
        >
        <we-button @click="sortModal = false" type="primary" size="small"
        ><em class="el-icon-search"></em> 确 定</we-button
        >
      </span>
    </el-dialog>

    <!-- 统计分析图表 -->
    <el-dialog
        title="常用统计分析图表"
        :visible.sync="commonAnalysePic"
        show-close
        custom-class="custom-dialog-half"
        @close="handleCommonly"
    >
      <div style="margin: 0 auto; width: 100%">
        <div class="chart_head">
          <!--          <span>导出Excel</span>-->
          <span @click="chartType = 1">饼图</span>
          <span @click="chartType = 2">曲线</span>
          <span @click="chartType = 3">柱状</span>
          <span style="border: none" @click="chartType = 4">雷达</span>
        </div>
        <el-table :data="erweiTableData"
                  border
                  :header-cell-style="{ background: '#cae8ea', color: '#333' }"
                  style="width:100%">
          <el-table-column  v-for='(item,i) in erweiTableTitle' :key="i" :prop="item" :label="item" show-overflow-tooltip>
          </el-table-column>
        </el-table>

        <ve-pie v-if="chartType === 1" :data="chartData"></ve-pie>
        <ve-line v-if="chartType === 2" :data="chartData"></ve-line>
        <ve-histogram v-if="chartType === 3" :data="chartData"></ve-histogram>
        <ve-radar v-if="chartType === 4" :data="chartData"></ve-radar>
      </div>
    </el-dialog>

    <!-- 常用统计分析 -->
    <el-dialog
        title="常用统计分析"
        :visible.sync="commonAnalyse"
        custom-class="custom-dialog-half"
    >
      <el-tree
          class="department-tree"
          node-key="uuid"
          :data="analyseData"
          :render-content="renderContent"
          :props="defaultProps"
          default-expand-all
          highlight-current
          :check-strictly="true"
          ref="statisticsTree"
      >
      </el-tree>
      <div slot="footer" class="dialog-footer">
        <we-button size="mini" @click="treeEdit" style="margin-right: 30px"
        >编 辑
        </we-button
        >
        <we-button size="mini" @click="treeDel" style="margin-right: 30px"
        >删 除
        </we-button
        >
        <we-button size="mini" style="margin-right: 30px" @click="handleStatistics">开始统计</we-button>
        <we-button size="mini" @click="commonAnalyse = false">关闭</we-button>
      </div>
    </el-dialog>
    <!-- 常用统计分析 -->

    <!-- 自定义统计分析 -->
    <el-dialog
        title="自定义统计分析"
        :visible.sync="customAnalyse"
        show-close
        custom-class="custom-dialog-half"
    >
      <div style="width: 100%; display: flex; flex-wrap: wrap; height: 400px">
        <div class="box-class" @click="simpleStatistics">简单统计</div>
        <div class="box-class" @click="handleGeneralStatistics">通用统计</div>
        <div class="box-class" @click="handleTwoDimensional">二维统计</div>
        <div class="box-class" @click="individual = true">单项统计</div>
      </div>
    </el-dialog>
    <!-- 自定义统计分析 -->

    <!-- 通用统计 -->
    <el-dialog
        title="通用统计"
        :visible.sync="commonUse"
        :close-on-click-modal="false"
        top="10vh"
        @close="handleStatisticsTree"
    >
      <el-row :gutter="20" style="margin-top: 10px">
        <el-col :span="5">
          <div>
            <el-select
                @change="selectSubsetUuid"
                v-model="subsetUuid"
                filterable
                size="mini"
                style="width: 100%"
            >
              <el-option
                  v-for="(item,index) in allSubset"
                  :key="index"
                  :label="item.name"
                  :value="item"
              >
              </el-option>
            </el-select>
          </div>
          <div class="col_h_b">
            <el-checkbox-group
                v-model="checkedLeft"
                @change="handleLeftCheckbox"
                style="margin-top: 15px">
              <div
                  style="line-height: 20px"
                  v-for="(item, index) in left"
                  :key="index"
              >
                <el-checkbox
                    :checked="item.checked"
                    :label="item"
                    style="margin-right: 5px"
                >
                  <img :src="item.type === 'input'
                  ?require('@/assets/img/abc.png'):item.type === 'number'
                  ?require('@/assets/img/123.png'):item.type === 'date'
                  ?require('@/assets/img/calendar.png'):require('@/assets/img/select.png')"
                       style="width: 16px;height: 16px;" alt=""/>
                  {{ item.fieldName }}
                </el-checkbox
                >
              </div>
            </el-checkbox-group>
          </div>
        </el-col>
        <el-col :span="1">
          <div style="margin-top: 70px; text-align: center">
            <el-button
                @click="toRight"
                type="primary"
                style="width: 10px"
                size="small"
            ><em class="el-icon-arrow-right" style="margin: -10px"></em>
            </el-button>
          </div>
          <div style="margin-top: 40px; text-align: center">
            <el-button
                @click="toLeft"
                type="primary"
                style="width: 10px"
                size="small"
            ><em class="el-icon-arrow-left" style="margin: -10px"></em>
            </el-button>
          </div>
        </el-col>
        <el-col :span="11">
          <div>
            <div style="float: right">
              <we-button type="primary" size="small" @click="toLeft"
              ><em class="el-icon-delete"></em> 删除
              </we-button>
              <we-button type="primary" size="small" @click="delAll"
              ><em class="el-icon-delete-solid"></em> 全部删除
              </we-button>
            </div>
            <div style="margin-top: 10px; clear: both; height: 280px">
              <el-row class="line_h" :gutter="10">
                <el-col :span="8" style="padding-left: 30px">统计指标项</el-col>
                <el-col :span="5.2">关系(运算符)</el-col>
                <el-col :span="9" style="padding-left: 30px">查询值</el-col>
              </el-row>
              <el-checkbox-group v-model="checkedRight">
                <el-row
                    class="line_h"
                    :gutter="10"
                    v-for="(item, index) in right"
                    :key="index"
                >
                  <el-col :span="8" class="text_one_row">
                    <el-checkbox
                        class="right-label"
                        :label="item"
                        @change="singleChoice(index)"
                        style="margin-right: 5px"
                    >{{ index + 1 }} {{ item.fieldName }}
                    </el-checkbox
                    >
                  </el-col>
                  <el-col style="width: 96px;">
                    <el-select
                        v-model="item.operation"
                        @change="selectSet(index)"
                        :value-key="item.operation"
                        size="mini"
                    >
                      <el-option
                          v-for="i in operationList"
                          :key="i.value"
                          v-if="((item.type === 'number' || item.type === 'date') && i.value !== 'IN' && i.value !== 'NOT_IN'&& i.value !== 'START'
                                    && i.value !== 'NOT_START'&& i.value !== 'END'&& i.value !== 'NOT_END')
                                || ((item.type === 'input' || item.type === 'tree' || item.type === 'radio')
                                    && i.value !== 'LESS_THAN' && i.value !== 'MORE_THAN')"
                          :label="i.label"
                          :value="i.value"
                      >
                      </el-option>
                    </el-select>
                  </el-col>
                  <el-col :span="9" class="text_one_row">
                    <el-input size="mini" v-if="item.type==='input'" v-model="item.value"></el-input>
                    <el-input size="mini" v-if="item.type==='number'" v-model.number="item.value"
                              @blur="leaveJudgment(index)"></el-input>
                    <el-select
                        v-if="item.type === 'radio'"
                        @change="selectSet(index)"
                        v-model="item.value"
                        size="mini"
                    >
                      <el-option
                          v-for="i in item.inquire"
                          :key="i.uuid"
                          :label="i.name"
                          :value="i.uuid"
                      >
                      </el-option>
                    </el-select>
                    <el-cascader
                        v-if="item.type === 'tree'"
                        ref="Company"
                        class="inputW"
                        v-model="item.value"
                        :show-all-levels="false"
                        :props="{ value: 'uuid', label: 'name',expandTrigger: 'hover',checkStrictly: true }"
                        :options="item.inquire"
                    ></el-cascader>
                    <el-date-picker
                        v-if="item.type === 'date'"
                        v-model="item.value"
                        size="mini"
                        type="date"
                        placeholder="选择日期">
                    </el-date-picker>
                  </el-col>
                </el-row>
              </el-checkbox-group>
            </div>
            <div style="display: flex; justify-content: space-evenly">
              <we-button @click="createSql(1)" size="small">并且</we-button>
              <we-button @click="createSql(2)" size="small">或者</we-button>
              <we-button @click="createSql(3)" size="small">(</we-button>
              <we-button @click="createSql(4)" size="small">)</we-button>
            </div>
            <div style="margin-top: 10px">
              <el-input
                  v-model="sqlValue"
                  type="textarea"
                  :autosize="{ minRows: 2, maxRows: 4 }"
                  placeholder="请输入统计逻辑条件
	如:(@1*@2)+@3表示:(@1 或者 @2) 并且 @3"
              >
              </el-input>
            </div>
            <div style="line-height: 50px">
              常用统计名称：
              <el-input
                  size="mini"
                  v-model="statisticalName"
                  style="width: 75%; margin-left: 5px"
                  placeholder="这里输入常用统计名称"
              ></el-input>
            </div>
            <div style="display: flex; justify-content: space-evenly">
              <we-button size="small" style="opacity: 0;"
              ><em class="el-icon-edit-outline"></em> 引入公式
              </we-button>
              <we-button size="small" @click="confirmationCondition"
              ><em class="el-icon-folder-opened"></em> 确认
              </we-button>
            </div>
          </div>
        </el-col>
        <el-col :span="6.4">
          <div
              style="
              color: #669900;
              border: 1px solid #eee;
              line-height: 25px;
              text-align: center;
            "
          >
            已建通用统计项，双击可以编辑
          </div>
          <div style="margin: 10px 0;display: flex;justify-content: space-evenly">
            <we-button @click="handleEitItem" size="mini" type="primary" style="margin-right: 30px">编 辑</we-button>
            <we-button @click="handleDeteleItem" size="mini" type="primary">删 除</we-button>
          </div>
          <div
              v-for="(item,index) in statisticsList" :key="index"
              @click="handleCheckStatistics(item,index)"
              @dblclick="handleStatisticsEit(item,index)"
              @mousedown.right="handleMouseDown(item,index,$event)"
              class="active_label" :class="activeLabel === index?'active_label_active':''">{{ item.name }}
          </div>
        </el-col>
      </el-row>
      <div slot="footer" class="dialog-footer">
        <we-button @click="handleSaveStatistics" size="mini" type="primary" style="margin-right: 30px"
        >保 存
        </we-button
        >
        <we-button @click="handleStatisticsCondition" size="mini" type="primary" style="margin-right: 30px"
        >统 计
        </we-button
        >
        <we-button size="mini" @click="handleStatisticsTree">关 闭</we-button>
      </div>
    </el-dialog>
    <!-- 选择保存到哪类 -->
    <el-dialog
        title="保存名称"
        :visible.sync="saveStatistics"
        show-close
        width="500px"
        @close="handleStatisticsBox"
    >
      <el-tree
          class="department-tree"
          node-key="id"
          :data="analyseData"
          :render-content="renderContent"
          :props="defaultProps"
          highlight-current
          :check-strictly="true"
          ref="saveStatistics"
      >
      </el-tree>
      <div style="display: flex">
        <div style="width: 120px;">保存名称:</div>
        <el-input placeholder="这里输入名称" size="mini" v-model="saveStatisticsName"></el-input>
      </div>
      <div slot="footer" class="dialog-footer">
        <we-button size="mini" @click="handleDeleteStatistics">删除</we-button>
        <we-button size="mini" @click="handleConfirm">确认</we-button>
        <we-button size="mini" @click="handleStatisticsBox">关闭</we-button>
      </div>
    </el-dialog>

    <!-- 简单统计 -->
    <el-dialog
        title="简单统计"
        :visible.sync="easyStatistics"
        :close-on-click-modal="false"
        top="10vh"
        width="60%"
    >
      <el-row :gutter="20" style="margin-top: 10px">
        <el-col :span="8">
          <div>
            <el-select
                @change="selectSubsetUuid"
                v-model="subsetUuid"
                filterable
                size="mini"
                style="width: 100%"
            >
              <el-option
                  v-for="(item,index) in allSubset"
                  :key="index"
                  :label="item.name"
                  :value="item"
              >
              </el-option>
            </el-select>
          </div>
          <div class="col_h_b">
            <el-checkbox-group
                @change="handleLeftCheckbox"
                v-model="checkedLeft"
                style="margin-top: 15px;"
            >
              <div
                  style="line-height: 20px;"
                  v-for="(item, index) in left"
                  :key="index"
              >
                <el-checkbox
                    :checked="item.checked"
                    :label="item"
                    style="margin-right: 5px"
                >
                  <img :src="item.type === 'input'
                  ?require('@/assets/img/abc.png'):item.type === 'number'
                  ?require('@/assets/img/123.png'):item.type === 'date'
                  ?require('@/assets/img/calendar.png'):require('@/assets/img/select.png')"
                       style="width: 16px;height: 16px;" alt=""/>
                  {{ item.fieldName }}
                </el-checkbox
                >
              </div>
            </el-checkbox-group>
          </div>
        </el-col>
        <el-col :span="2">
          <div style="margin-top: 70px; text-align: center">
            <el-button
                @click="toRight"
                type="primary"
                style="width: 10px"
                size="small"
            ><em class="el-icon-arrow-right" style="margin: -10px"></em>
            </el-button>
          </div>
          <div style="margin-top: 40px; text-align: center">
            <el-button
                @click="toLeft"
                type="primary"
                style="width: 10px"
                size="small"
            ><em class="el-icon-arrow-left" style="margin: -10px"></em>
            </el-button>
          </div>
        </el-col>
        <el-col :span="14">
          <div>
            <div style="float: right">
              <we-button type="primary" size="small" @click="toLeft"
              ><em class="el-icon-delete"></em> 删除
              </we-button>
              <we-button type="primary" size="small" @click="delAll"
              ><em class="el-icon-delete-solid"></em> 全部删除
              </we-button>
            </div>
          </div>
          <div style="margin-top: 10px; clear: both; height: 280px">
            <el-row class="line_h" :gutter="10">
              <el-col :span="7" style="padding-left: 30px">统计指标项</el-col>
              <el-col :span="5.2">关系(运算符)</el-col>
              <el-col :span="6">查询值</el-col>
              <el-col :span="4">描述值</el-col>
            </el-row>
            <el-checkbox-group v-model="checkedRight">
              <el-row
                  class="line_h"
                  :gutter="10"
                  v-for="(item, index) in right"
                  :key="index"
              >
                <el-col :span="7" class="text_one_row">
                  <el-checkbox :label="item" style="margin-right: 5px"
                  > {{ item.fieldName }}
                  </el-checkbox
                  >
                </el-col>
                <el-col :span="5">
                  <el-select
                      @change="selectSet(index)"
                      v-model="item.operation"
                      :value-key="item.operation"
                      size="mini"
                  >
                    <el-option
                        v-for="i in operationList"
                        :key="i.value"
                        v-if="((item.type === 'number' || item.type === 'date') && i.value !== 'IN' && i.value !== 'NOT_IN'&& i.value !== 'START'
                                    && i.value !== 'NOT_START'&& i.value !== 'END'&& i.value !== 'NOT_END')
                                || ((item.type === 'input' || item.type === 'tree' || item.type === 'radio')
                                    && i.value !== 'LESS_THAN' && i.value !== 'MORE_THAN')"
                        :label="i.label"
                        :value="i.value"
                    >
                    </el-option>
                  </el-select>
                </el-col>
                <el-col :span="5" class="text_one_row">
                  <el-input size="mini" v-if="item.type==='input'" v-model="item.value"></el-input>
                  <el-input size="mini" v-if="item.type==='number'" v-model.number="item.value"
                            @blur="leaveJudgment(index)"></el-input>
                  <el-select
                      v-if="item.type === 'radio'"
                      @change="selectSet(index)"
                      v-model="item.value"
                      size="mini"
                  >
                    <el-option
                        v-for="i in item.inquire"
                        :key="i.uuid"
                        :label="i.name"
                        :value="i.uuid"
                    >
                    </el-option>
                  </el-select>
                  <el-cascader
                      v-if="item.type === 'tree'"
                      ref="Company"
                      class="inputW"
                      v-model="item.value"
                      :show-all-levels="false"
                      :props="{ value: 'uuid', label: 'name',expandTrigger: 'hover',checkStrictly: true }"
                      :options="item.inquire"
                  ></el-cascader>
                  <el-date-picker
                      v-model="item.value"
                      v-if="item.type === 'date'"
                      size="mini"
                      type="date"
                      placeholder="选择日期">
                  </el-date-picker>
                </el-col>
                <el-col :span="5" class="text_one_row">
                  <el-input size="mini" v-model="item.description"></el-input>
                </el-col>
              </el-row>
            </el-checkbox-group>
          </div>
        </el-col>
      </el-row>
      <div slot="footer" class="dialog-footer">
        <we-button size="mini" @click="handleSaveEasy">保 存</we-button>
        <we-button size="mini" @click="handleEasy">统 计</we-button>
        <we-button size="mini" @click="easyStatistics = false">关 闭</we-button>
      </div>
    </el-dialog>
    <!-- 简单统计 -->

    <!-- 二维统计 -->
    <el-dialog
        title="二维统计"
        :visible.sync="twoDimensional"
        :close-on-click-modal="false"
        @close="closeTwoDimensional"
        top="10vh"
    >
      <el-row :gutter="20" style="height: 100px">
        <el-col :span="10" style="border: 1px dashed #ddd; height: 90px">
        </el-col>
        <el-col :span="14">
          <div class="erwei_title">横向统计分类选择</div>
          <div style="text-align: center; margin-top: 5px">
            <el-select
                v-model="erweiValue1"
                filterable
                size="mini"
                style="width: 230px"
            >
              <el-option
                  v-for="(item,index) in erweiList"
                  :key="index"
                  :label="item.name"
                  :value="item.uuid"
              >
              </el-option>
            </el-select>
          </div>
        </el-col>
      </el-row>
      <el-row :gutter="20" style="height: 200px">
        <el-col :span="10">
          <div class="erwei_title">纵向统计分类选择</div>
          <div style="text-align: center; margin-top: 5px">
            <el-select
                v-model="erweiValue2"
                filterable
                size="mini"
                style="width: 230px"
            >
              <el-option
                  v-for="(item,index) in erweiList"
                  :key="index"
                  :label="item.name"
                  :value="item.uuid"
              >
              </el-option>
            </el-select>
          </div>
        </el-col>
        <el-col :span="14">
          <div class="erwei_chart">二维统计图表</div>
        </el-col>
      </el-row>
      <div slot="footer" class="dialog-footer">
        <we-button
            size="mini"
            v-if="erweiValue1 !== erweiValue2"
            type="primary"
            style="margin-right: 30px"
            @click="saveTwoDimensional"
        >保 存
        </we-button
        >
        <we-button
            size="mini"
            @click="startTwoDimensional"
            v-if="erweiValue1 !== erweiValue2"
            type="primary"
            style="margin-right: 30px"
        >统 计
        </we-button
        >
        <we-button size="mini" @click="closeTwoDimensional">关 闭</we-button>
      </div>
    </el-dialog>
    <!-- 二维统计 -->

    <!-- 二维统计按钮 -->
    <el-dialog
        title="统计分析"
        :visible.sync="erweiTable"
        show-close
        custom-class="custom-dialog-half"
    >
      <div style="margin: 0 auto; width: 100%">
        <div class="chart_head">
<!--          <span>导出Excel</span>-->
          <span @click="chartType = 1">饼图</span>
          <span @click="chartType = 2">曲线</span>
          <span @click="chartType = 3">柱状</span>
          <span style="border: none" @click="chartType = 4">雷达</span>
        </div>
        <el-table :data="erweiTableData"
                  border
                  :header-cell-style="{ background: '#cae8ea', color: '#333' }"
                  style="width:100%">
          <el-table-column  v-for='(item,i) in erweiTableTitle' :key="i" :label="item" show-overflow-tooltip>
            <template slot-scope="scope">
              {{scope.row[i] }}
            </template>
          </el-table-column>
        </el-table>

        <ve-pie v-if="chartType === 1" :data="chartData"></ve-pie>
        <ve-line v-if="chartType === 2" :data="chartData"></ve-line>
        <ve-histogram v-if="chartType === 3" :data="chartData"></ve-histogram>
        <ve-radar v-if="chartType === 4" :data="chartData"></ve-radar>
      </div>
    </el-dialog>
    <!-- 二维统计按钮 -->

    <!-- 单项统计 -->
    <el-dialog
        title="单项统计"
        :visible.sync="individual"
        :close-on-click-modal="false"
        top="10vh"
        width="50%"
    >
      <el-row :gutter="20" style="margin-top: 10px; margin-left: 20px">
        <el-col :span="8">
          <div>
            <el-select
                @change="selectSubsetUuid"
                v-model="subsetUuid"
                filterable
                size="mini"
                style="width: 100%"
            >
              <el-option
                  v-for="(item,index) in allSubset"
                  :key="index"
                  :label="item.name"
                  :value="item"
              >
              </el-option>
            </el-select>
          </div>
          <div class="col_h_b" style="height: 350px">
            <el-checkbox-group
                @change="handleLeftCheckbox"
                v-model="checkedLeft"
                style="margin-top: 15px"
            >
              <div
                  style="line-height: 20px"
                  v-for="(item, index) in left"
                  :key="index"
              >
                <el-checkbox
                    v-if="item.type === 'date' || item.type === 'number'"
                    :checked="item.checked"
                    :label="item"
                    style="margin-right: 5px"
                >
                  <img :src="item.type === 'input'
                  ?require('@/assets/img/abc.png'):item.type === 'number'
                  ?require('@/assets/img/123.png'):item.type === 'date'
                  ?require('@/assets/img/calendar.png'):require('@/assets/img/select.png')"
                       style="width: 16px;height: 16px;" alt=""/>
                  {{ item.fieldName }}
                </el-checkbox
                >
              </div>
            </el-checkbox-group>
          </div>
        </el-col>
        <el-col :span="14">
          <div class="individual_line" style="margin-top: 10px">
            <span class="individual_title">计算类型</span>
            <el-radio-group v-model="radio">
              <div>
                <el-radio :label="'SUM'">求和值</el-radio>
                <el-radio :label="'MAX'">最大值</el-radio>
              </div>
              <div style="height: 10px"></div>
              <div>
                <el-radio :label="'MIN'">最小值</el-radio>
                <el-radio :label="'AVG'">平均值</el-radio>
              </div>
            </el-radio-group>
          </div>
          <div class="individual_line">
            <div style="width: 100%">
              <div>
                <span class="individual_title" style="color: #cc0000"
                >计算值</span
                >
                数<span style="opacity: 0">的</span>量：
                <el-input
                    size="mini"
                    placeholder="总数"
                    v-model="easyNum"
                    style="width: 70%; margin-left: 10px"
                ></el-input>
              </div>
              <div style="height: 10px"></div>
              <div>
                {{ radio === 'SUM' ? '求和值': radio === 'MAX' ? '最大值': radio === 'MIN' ? '最小值': '平均值'}}：
                <el-input
                    size="mini"
                    style="width: 70%; margin-left: 10px"
                    v-model="easySum"
                ></el-input>
              </div>
            </div>
          </div>
          <div class="individual_line">
            <span class="individual_title">时间设置</span>
            <div v-show="timeSetting">
              截止日期：
              <el-date-picker
                  type="date"
                  placeholder="选择日期"
                  v-model="time"
                  size="mini"
              >
              </el-date-picker>
            </div>
          </div>
        </el-col>
      </el-row>
      <div slot="footer" class="dialog-footer">
        <we-button @click="handleCalculation" size="mini" type="primary" style="margin-right: 30px"
        >计 算
        </we-button
        >
        <we-button size="mini" @click="individual = false">关 闭</we-button>
      </div>
    </el-dialog>
    <!-- 单项统计 -->

    <!-- 智能导入 -->
    <el-dialog
        title="选择导入的EXCEL"
        :visible.sync="intelligence"
        class="dialogClass"
        @close="closeExcel"
        :close-on-click-modal="false"
        top="10vh"
        width="60%"
    >
      <el-steps :active="active" finish-status="success" simple>
        <el-step title="Excel上传"></el-step>
        <el-step title="指标映射"></el-step>
        <el-step title="常数映射"></el-step>
        <el-step title="模板维护"></el-step>
        <el-step title="数据导入"></el-step>
      </el-steps>
      <div v-if="active === 1" style="height: 400px">
        <div
            style="
            padding: 15px;
            color: #cc0000;
            border: 1px solid #aaa;
            margin-top: 10px;
          "
        >
          选择需要上传的Excel文件；设置Excel头部读取开始的行号；选择已经保存过的模板。
        </div>
        <div style="margin-top: 10px; display: flex">
          <span>选择上传文件：</span>
          <el-input
              type="text"
              :value="ExcelName"
              disabled="disabled"
              size="mini"
              style="width: 70%"
          ></el-input>
          <el-upload
              size="mini"
              class="upload-demo"
              action="https://jsonplaceholder.typicode.com/posts/"
              :http-request="importExcel"
              :before-upload="beforeUpload"
          >
            <we-button size="mini">...</we-button>
          </el-upload>
        </div>
        <div style="margin-top: 10px">
          <span>设置开始行号：</span>
          <el-input size="mini" style="width: 50%" v-model.number="startLineNumber"
                    @input="leaveLineJudgment" @blur="reselectExcel(excelFile)"></el-input>
        </div>
        <div style="margin-top: 10px">
          <span>选择配置模板：</span>
          <el-select
              v-model="selectTemplate"
              @change="handleSelect"
              filterable
              size="mini"
              style="width: 80%"
          >
            <el-option
                v-for="(item,index) in smartImportList"
                :key="index"
                :label="item.name"
                :value="item"
            >
            </el-option>
          </el-select>
        </div>
      </div>
      <div v-if="active === 2">
        <el-row :gutter="20">
          <el-col :span="8">
            <div style="font-size: 16px;font-weight: 600;color: #181afe">Excel中指标</div>
            <div class="col_h_b">
              <el-checkbox-group
                  v-model="checkedLeft"
                  @change="handleLeftCheckbox"
                  style="margin-top: 15px">
                <div
                    style="line-height: 20px"
                    v-for="(item, index) in excelIndexList"
                    :key="index"
                >
                  <el-checkbox
                      :checked="item.checked"
                      :label="item"
                      style="margin-right: 5px"
                  >
                    {{ item.name }}
                  </el-checkbox
                  >
                </div>
              </el-checkbox-group>
            </div>
          </el-col>
          <el-col :span="16">
            <div>
              <span style="font-size: 16px;font-weight: 600;margin-right: 16px;color: #181afe">
                系统中指标<i class="el-icon-bottom"></i>
              </span>
              <span style="font-size: 16px;font-weight: 600;">选择指标集 </span>
              <el-select
                  @change="selectSubsetUuid"
                  v-model="subsetUuid"
                  filterable
                  size="mini"
                  style="width: 40%"
              >
                <el-option
                    v-for="(item,index) in allSubset"
                    :key="index"
                    :label="item.name"
                    :value="item"
                >
                </el-option>
              </el-select>
            </div>
            <div style="height: 250px; overflow-y: auto">
              <el-checkbox-group
                  @change="handleRightCheckbox"
                  v-model="checkedRight"
                  style="margin-top: 10px"
              >
                <div
                    style="line-height: 10px"
                    v-for="(item, index) in left"
                    :key="index"
                >
                  <el-checkbox
                      :checked="item.checked"
                      :label="item"
                      style="margin-right: 5px"
                  >
                    <img :src="item.type === 'input'
                  ?require('@/assets/img/abc.png'):item.type === 'number'
                  ?require('@/assets/img/123.png'):item.type === 'date'
                  ?require('@/assets/img/calendar.png'):require('@/assets/img/select.png')"
                         style="width: 16px;height: 16px;" alt=""/>
                    {{ item.fieldName }}
                  </el-checkbox
                  >
                </div>
              </el-checkbox-group>
            </div>
            <div>
              <we-button size="small" @click="manualMatch">手动匹配</we-button>
              <we-button size="small" @click="smartMatchingCurrent">智能匹配当前集</we-button>
              <we-button size="small" @click="smartMatchingAll">智能匹配所有集</we-button>
              <we-button type="primary" size="small" @click="delSelectTable"
              ><em class="el-icon-delete"></em> 删除
              </we-button>
              <we-button type="primary" size="small" @click="delAll"
              ><em class="el-icon-delete-solid"></em> 全部删除
              </we-button>
            </div>
            <div>
              <el-table
                  size="mini"
                  :cell-style="{ height: '30px', padding: '0px' }"
                  :header-cell-style="{ height: '35px', padding: '0px' }"
                  ref="singleTableOne"
                  :data="table2Data"
                  @row-click="handleTable2Data"
                  highlight-current-row
                  style="width: 100%"
              >
                <el-table-column type="index" width="50"></el-table-column>
                <el-table-column
                    property="excel"
                    label="Excel指标"
                    width="120"
                ></el-table-column>
                <el-table-column
                    property="system"
                    label="系统指标"
                    width="120"
                ></el-table-column>
                <el-table-column
                    property="table"
                    label="系统指标集"
                ></el-table-column>
              </el-table>
            </div>
          </el-col>
        </el-row>
      </div>
      <div v-if="active === 3">
        <el-row :gutter="20">
          <el-col :span="8">
            <div style="font-size: 16px;font-weight: 600;color: #181afe">Excel中指标</div>
            <div class="col_h_b">
              <el-checkbox-group
                  v-model="checkedLeft"
                  @change="handleLeftCheckbox"
                  style="margin-top: 15px">
                <div
                    style="line-height: 20px"
                    v-for="(item, index) in excelCommonlyList"
                    :key="index"
                >
                  <el-checkbox
                      :checked="item.checked"
                      :label="item"
                      style="margin-right: 5px"
                  >
                    {{ item.fieldName }}
                  </el-checkbox
                  >
                </div>
              </el-checkbox-group>
            </div>
          </el-col>
          <el-col :span="16">
            <el-row :gutter="20">
              <el-col :span="12" style="height: 250px">
                <div style="font-size: 16px;font-weight: 600;color: #181afe">
                Excel中常数值<i class="el-icon-bottom"></i>
              </div>
              <el-tree
                  class="department-tree"
                  style="height: 210px;border:1px solid rgba(0,0,0,0.08);overflow-y: auto"
                  node-key="id"
                  :data="excelConstantList"
                  :props="defaultProps"
                  highlight-current
                  :check-strictly="true"
                  ref="excelConstantList"
              >
              </el-tree>
              </el-col>
              <el-col :span="12" style="height: 250px">
                <div style="font-size: 16px;font-weight: 600;color: #181afe">
                系统中常数值<i class="el-icon-bottom"></i>
                </div>
                <el-tree
                    class="department-tree"
                    style="height: 210px;border:1px solid rgba(0,0,0,0.08);overflow-y: auto"
                    node-key="id"
                    :data="systemConstantList"
                    :props="defaultProps"
                    highlight-current
                    :check-strictly="true"
                    ref="systemConstantList"
                >
                </el-tree>
              </el-col>
            </el-row>
            <div>
              <we-button size="small" @click="constantMatch">手动匹配</we-button>
              <we-button size="small" @click="smartConstantCurrent">智能匹配</we-button>
<!--              <we-button size="small" @click="manualMatch">名称/编码匹配</we-button>-->
              <we-button type="primary" size="mini" @click="delSelectTable3"
              ><em class="el-icon-delete"></em> 删除
              </we-button>
              <we-button type="primary" size="mini" @click="delAll"
              ><em class="el-icon-delete-solid"></em> 全部删除
              </we-button>
            </div>
            <div>
              <el-table
                  size="mini"
                  :cell-style="{ height: '30px', padding: '0px' }"
                  :header-cell-style="{ height: '35px', padding: '0px' }"
                  ref="singleTable"
                  :data="table3Data"
                  @row-click="handleTable3Data"
                  highlight-current-row
                  style="width: 100%"
              >
                <el-table-column type="index" width="50"></el-table-column>
                <el-table-column v-for="item in table3Title" :key="item.value"
                    :property="item.value"
                    :label="item.name"
                ></el-table-column>
              </el-table>
            </div>
          </el-col>
        </el-row>
      </div>
      <div v-if="active === 4">
        <div style="width: 70%; margin: 0 auto">
          <div style="padding: 30px 0; color: #cc0000">
            您可以在此页面，对配置的模板进行新增、修改或者删除操作
          </div>
          <div style="display: flex">
            <div
                style="
                width: 80%;
                border: 1px solid #99bbe8;
                padding: 5px 15px;
                height: 350px;
              "
            >
              <el-tree
                  class="department-tree"
                  node-key="id"
                  :data="smartImportList"
                  :props="defaultProps"
                  highlight-current
                  :check-strictly="true"
                  ref="smartImport"
              >
              </el-tree>
            </div>
            <div style="margin-left: 30px">
              <we-button @click="handleSmart('add')" size="mini" style="display: block">新 增</we-button>
              <we-button @click="handleSmart('eit')" size="mini" style="display: block; margin: 35px 0"
              >修 改
              </we-button
              >
              <we-button @click="handleDeleteSmart" size="mini" style="display: block">删 除</we-button>
            </div>
          </div>
        </div>
      </div>
      <div v-if="active === 5">
        <el-collapse v-model="activeNames">
          <el-collapse-item
              title="高级设置(人员库、子集导入方式、数据更新方式)"
              name="1"
          >
            <div style="display: flex; padding: 0 30px">
              <div style="flex: 1">
                <span class="active_title">人员库</span>
                <div class="active_box">
                  <el-select v-model="getStatus" size="mini" style="width: 70%">
                    <el-option
                        v-for="item in PersonnelLib"
                        :key="item.uuid"
                        :label="item.itemText"
                        :value="item.uuid"
                    >
                    </el-option>
                  </el-select>
                </div>
              </div>
              <div style="flex: 1; margin: 0 10px">
                <span class="active_title">子集导入方式</span>
                <div class="active_box">
                  <el-radio style="color: #008000" v-model="smartRadio" label="0"
                  >新增式
                  </el-radio
                  >
                  <el-radio style="color: #ff0000" v-model="smartRadio" label="1"
                  >覆盖式
                  </el-radio
                  >
                </div>
              </div>
              <div style="flex: 1">
                <span class="active_title">数据更新方式</span>
                <div class="active_box">
                  <el-checkbox-group v-model="updateMethod">
                    <el-checkbox label="empty" style="color: #ff0000">清空式</el-checkbox>
                    <el-checkbox v-show="updateMethod.includes('empty')" label="more" style="color: #ff0000">多子集</el-checkbox>
                  </el-checkbox-group>
                </div>
              </div>
            </div>
          </el-collapse-item>
        </el-collapse>
        <div style="padding: 0 30px">
          <span class="active_title">选择要导入的Excel</span>
          <div class="active_box" style="text-align: left; height: auto">
            <span style="margin-left: 20px">Excel模板：</span>
            <el-input
                type="text"
                :value="ExcelName"
                disabled="disabled"
                size="mini"
                style="width: 30%"
            ></el-input>
            <el-upload
                size="mini"
                style="display: inline-block;margin-left: 6px"
                action="https://jsonplaceholder.typicode.com/posts/"
                :show-file-list="false"
                :http-request="importExcel"
                :before-upload="beforeUpload"
            >
              <we-button v-show="disabledBrowse" size="mini">浏览...</we-button>
            </el-upload>
            <div style="text-align: center; margin-top: 20px">
              <we-button size="mini" @click="handleStartImport">开始导入</we-button>
            </div>
          </div>
<!--          <div>-->
<!--            <div style="font-size: 15px; font-weight: 700; margin-top: 10px">-->
<!--              导入处理信息-->
<!--            </div>-->
<!--          </div>-->
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <we-button
            v-if="active === 1 && isTemplateImport"
            @click="handleDataImport"
            size="mini"
            type="primary"
            style="margin-right: 30px"
        >数据导入
        </we-button
        >
        <we-button
            v-if="active !== 1"
            @click="active--"
            size="mini"
            type="primary"
            style="margin-right: 30px"
        >上一步
        </we-button
        >
        <we-button
            v-if="active !== 5"
            @click="next"
            size="mini"
            type="primary"
            style="margin-right: 30px"
        >下一步
        </we-button
        >
        <we-button size="mini" @click="closeExcel">关 闭</we-button>
      </div>
    </el-dialog>

    <!-- 批处理组件列表 -->
    <component v-for="i of batchOperation" :key="i.value" :is="i.value" :ref="i.value"
               @handleModifyDialog="handleModifyDialog"
               @handleOffDialog="batchValue = []" />
  </div>
</template>

<script>
import draggable from "vuedraggable";
import WeButton from "@/components/WeButton";
import WePagination from "@/components/WePagination";
import PersonnelBaseModal from "./PersonnelBaseModal";
import Sortable from "sortablejs";
import XLSX from 'xlsx'
import {bus} from "@/utils/eventBus";
import {getAction, postAction, deleteAction, putAction} from "@/api/manage";
import {getSourceColumnCode, getColumn} from "./column.js";
import EditMaster from './components/BatchHandle/EditMaster'
import AddChildren from './components/BatchHandle/AddChildren'
import EditChildren from './components/BatchHandle/EditChildren'
import DelChildren from './components/BatchHandle/DelChildren'
import ImportPhoto from './components/BatchHandle/ImportPhoto'
import ExportPhoto from './components/BatchHandle/ExportPhoto'
import DelPhoto from './components/BatchHandle/DelPhoto'
import {
  baseStaff,
  baseStaffCount,
  opCondition,
  opCorePropertyValue,
  opCount, opDictNew,
  OpPour,
  queryCondition
} from "@/api/apiUrl";

const columns = getColumn(this);
const deleteSubset = [];

export default {
  components: {
    draggable,
    WeButton,
    WePagination,
    PersonnelBaseModal,
    EditMaster,
    AddChildren,
    EditChildren,
    DelChildren,
    ImportPhoto,
    ExportPhoto,
    DelPhoto
  },
  watch: {
    query(value) {
      // console.log(value)
      const str = "";
      this.queryArray = value;
    },
    "$store.state.personnelStatus"(newval) {
      this.personnelStatus = newval;
      this.fixedId = ''
      this.isFixedCondition = false
      this.isFixedConditionList = []
      this.isFixedConditionSql = ''
      this.getList();
    },
    // 简单统计
    easyStatistics(val) {
      this.clearDialog(val);
    },
    // 通用统计
    commonUse(val) {
      this.clearDialog(val);
    },
    // 二维统计
    twoDimensional(val) {
      this.clearDialog(val);
    },
    // 单项统计
    individual(val) {
      this.clearDialog(val);
    },
    // 通用统计项
    statisticsList(val) {
      if(!val.length) this.activeLabel = -1
    }
  },
  data() {
    return {
      activeNames: ["1"],
      chartData: {
        columns: ["name", "value"],
        rows: []
      },
      chartType: 0,
      fields: "1",
      seen: false, // 显示大图
      showImg: "", // 显示大图
      picUrl:  window.serverUrl.url + baseStaff.upload,
      eitPhoto: false,
      eitPhotoTitle: '',
      imageUrl: '',
      noPhotos: false,
      fieldPick: false,
      commonUse: false,
      PersonnelStatus: [], // 人员状态
      PersonnelLib: [], // 人员状态 数据导入用
      getStatus: "", // 选中人员状态 数据导入用
      national: "", // 少数民族
      isNoPartyMember: "", // 中共党员
      sex: "", // 性别
      photo: "", // 有无照片
      updateStatus: "",
      excelFile: null,
      disabledBrowse: false,
      fixedId: '',
      startLineNumber: 1,
      sortArray: [
        {id: 1, name: "www.itxst.com"},
        {id: 2, name: "www.jd.com"},
        {id: 3, name: "www.baidu.com"},
        {id: 3, name: "www.taobao.com"},
      ],
      batchOperation: Object.freeze([
        {
          value: 'EditMaster',
          label: '批量修改主集',
          children: [
            {
              value: 0,
              label: '已选人员'
            },
            {
              value: 1,
              label: '查询结果'
            }
          ]
        },
        {
          value: 'AddChildren',
          label: '批量添加子集',
          children: [
            {
              value: 0,
              label: '已选人员'
            },
            {
              value: 1,
              label: '查询结果'
            }
          ]
        },
        {
          value: 'EditChildren',
          label: '批量编辑子集',
          children: [
            {
              value: 0,
              label: '已选人员'
            },
            {
              value: 1,
              label: '查询结果'
            }
          ]
        },
        {
          value: 'DelChildren',
          label: '批量删除子集'
        },
        {
          value: 'ImportPhoto',
          label: '批量导入照片'
        },
        {
          value: 'ExportPhoto',
          label: '批量导出照片',
          children: [
            {
              value: 0,
              label: '已选人员'
            },
            {
              value: 1,
              label: '查询结果'
            }
          ]
        },
        {
          value: 'DelPhoto',
          label: '批量删除照片',
          children: [
            {
              value: 0,
              label: '已选人员'
            },
            {
              value: 1,
              label: '查询结果'
            }
          ]
        }
      ]),
      batchValue: [],
      personnelStatus: "57f0fb9912734063ba0190bd0efbac53", // 查询人员状态
      personneluuids: [], // 选中人员的uuid
      ageMax: '',
      ageMin: '',
      degreeMax: '',
      departmentList: [],
      educationType: '',
      jobCategory: '',
      degreeMin: '',
      positionLevel: '',
      centerDialogVisible: false,
      allSubset: [], // 所有的子集
      smartImportList: [], // 智能导入列表
      selectSubset: "", // 选中批量操作的子集
      isUpdateSubset: false, // 是否是批量修改
      isDeleteSubset: false, // 是否是批量删除
      showOverflow: true,
      checkAll: false,
      deleteSubset: [], // 批量删除子集的名字
      checkedDelete: [], // 批量删除选中的子集的名字
      selectDelete: [], // 选中批量操作删除子集 走接口
      left: [], // 左侧 子集字段数据
      right: [], // 右边数据
      subsetUuid: "", // 左侧 选中子集的uuid
      checkedLeft: [], // 左侧 选中子集的uuid集合
      checkedRight: [], // 选中右边数据
      sqlValue: "", // 构建出的sql
      statisticalName: "", // 统计名称
      radio: 'SUM', // 单项统计 计算类型
      smartRadio: '0', // 智能导入 子集导入方式
      updateMethod: [], // 数据更新方式
      time: "", // 单项统计 时间设置
      easyNum: "", // 计算值
      easySum: "", // 求和值
      operation: "", // 选择的计算符
      isEitstatistics: false,
      isEitstatisticsTree: false, //常用统计分析树编辑
      operationList: [
        {label: "等于", value: "EQUAL"},
        {label: "不等于", value: "NOT_EQUAL"},
        {label: "包含字符", value: "IN"},
        {label: "不包含字符", value: "NOT_IN"},
        {label: "以...开头", value: "START"},
        {label: "不以...开头", value: "NOT_START"},
        {label: "以...结尾", value: "END"},
        {label: "不以...结尾", value: "NOT_END"},
        {label: "为空", value: "NULL"},
        {label: "不为空", value: "NOT_NULL"},
        {label: "空白", value: "BLANK"},
        {label: "非空白", value: "NOT_BLANK"},
        {label: "小于", value: "LESS_THAN"},
        {label: "大于", value: "MORE_THAN"},
      ],
      statisticsList: [],
      easyStatistics: false, // 简单统计的dialog
      twoDimensional: false, // 二维统计的dialog
      erweiTable: false, // 二维统计的统计按钮 dialog
      erweiValue1: "", // 二维统计选择的值 横轴
      erweiValue2: "", // 二维统计选择的值 纵轴
      erweiTableData: [], // 二维统计的统计表数据
      erweiTableTitle: [''], // 二维统计的统计表表头
      erweiList: [], // 二维统计下拉框
      individual: false, // 单项统计的dialog
      timeSetting: false, // 单项统计 时间设置是否显示，
      isTemplateImport: false, // 数据导入是否显示，
      easyStatisticsTab: 0,
      easyStatisticsKey: 0,
      intelligence: false, // 智能导入 dialog
      active: 1, // 智能导入 步骤条
      ExcelName: "", // 智能导入 Excel名字
      table2Data: [], // 智能导入 第二步
      table2DelItem: null, // 智能导入 第二步
      table3DelItem: null, // 智能导入 第三步
      table3Data: [], // 智能导入 第三步
      headerCode: [],
      excelUpList: [],
      excelKeys: [],
      activeExcel: true,
      excelIndexList: [],
      excelCommonlyList: [],
      excelConstantList: [],
      systemConstantList: [],
      selectTemplate: '',
      excelFileList: [],
      table3Title: Object.freeze([
        { name: 'Excel常数', value: 'excelName'},
        { name: '系统常数', value: 'systemName'}
      ]),
      isIndeterminate: true,
      pagerConfig: {
        total: 10,
        currentPage: 1,
        pageSize: 10,
        pageSizes: [10, 20, 50, 100, 200, 500],
      },
      gridOptions: {
        border: true,
        resizable: true,
        showOverflow: true,
        columnKey: true,
        align: "left",
        radioConfig: {trigger: "row", highlight: true},
        toolbarConfig: {
          slots: {
            buttons: "toolbar_buttons",
          },
          custom: true,
        },
        columns,
        data: [],
      },
      sortModal: false,
      commonAnalyse: false, // 常用统计分析dialog
      commonAnalysePic: false, // 常用统计分析图表
      customAnalyse: false,
      currentPage: 1,
      drag: false,
      sortable: null,
      selectRow: null,
      clickRow: null,
      isEit: false,
      isFixedCondition: false,
      isFixedConditionList: [],
      isFixedConditionSql: '',
      showModal: false,
      showQuery: false,
      saveStatistics: false,
      saveStatisticsName: '',
      sortedColumns: getSourceColumnCode(),
      baseCode: "",
      analyseData: [
        {
          uuid: 'null1',
          name: "基本信息类",
          type: 'file',
          children: [],
        },
        {
          uuid: 'null2',
          name: "干部统计类",
          type: 'file',
          children: []
        },
        {
          uuid: 'null3',
          name: "其他类",
          type: 'file',
          children: []
        },
      ],
      activeLabel: -1,
      renderContent: function (h, {node, data, store}) {
        let addElement = arguments[0];
        if (data.type === 'file') {
          return addElement('span', [
            addElement('i', {class: "iconfont icon-weibiaoti-_huabanfuben", style: "color: rgb(255,231,147)"}),
            addElement('span', "    "),
            addElement('span', arguments[1].node.label)
          ]);
        } else {
          return addElement('span', [
            addElement('i', {class: "el-icon-s-data", style: "color: rgb(117,120,225)"}),
            addElement('span', "    "),
            addElement('span', arguments[1].node.label)
          ]);
        }
      },
      allGroupList: [],
      defaultProps: {
        children: "children",
        label: "name",
      },
      simpleCountList: [],
      sexDict: [],
      nationalDict: [],
      VxeLoading: false,
      dataEnd: "",
      batchAddFunc:null
    };
  },
  created() {
    this.baseCode = this.$route.query.uuid;
    this.personnelStatus = this.$store.state.personnelStatus;
    this.getList();
    this.getPersonnelStatus();
    this.columnDrop();
  },

  mounted() {
    window.t7est = this.test;
    this.getSubset()
    this.getSmartImport()
    localStorage.removeItem("person")
    getAction(opCorePropertyValue.newGetPropertyList, {
      value: 'sex'
    }).then(result => {
      this.sexDict = result.data.list1
    })
    getAction('/national/nationalList').then(result => {
      this.nationalDict = result.data
    })
    bus.$on ('handleDialog', ()=> {
      this.batchValue = []
    })
    bus.$on('sendBus', data => {
      this.fixedId = ''
      this.isFixedCondition = false
      this.isFixedConditionList = []
      this.isFixedConditionSql = ''
      this.departmentList = []
      this.national = ''
      this.sex = ''
      this.isNoPartyMember = ''
      this.ageMax = ''
      this.ageMin = ''
      this.degreeMax = ''
      this.degreeMin = ''
      this.positionLevel = ''
      this.educationType = ''
      this.jobCategory = ''
      if (data.id) {
        this.departmentList.push(data.id)
      }
      if (data.national) {
        this.national = data.national;
      }
      if (data.sex) {
        this.sex = data.sex;
      }
      if (data.isNoPartyMember) {
        this.isNoPartyMember = data.isNoPartyMember;
      }
      if (data.ageMax) {
        this.ageMax = data.ageMax;
      }
      if (data.ageMin) {
        this.ageMin = data.ageMin;
      }
      if (data.degreeMax) {
        this.degreeMax = data.degreeMax;
      }
      if (data.degreeMin) {
        this.degreeMin = data.degreeMin;
      }
      if (data.departmentList) {
        this.departmentList = data.departmentList;
      }
      if (data.educationType) {
        this.educationType = data.educationType;
      }
      if (data.jobCategory) {
        this.jobCategory = data.jobCategory;
      }
      if (data.positionLevel) {
        this.positionLevel = data.positionLevel;
      }
      if (data.dataEnd) {
        this.dataEnd = data.dataEnd;
      }
      this.getList();
    });
    bus.$on('sendBusFixed', result => {
      if(result.id) {
        this.fixedId = result.id
      }else{
        this.fixedId = 'fixed'
        this.isFixedCondition = result.isisFixedCondition
        this.isFixedConditionList = result.list
        this.isFixedConditionSql = result.sqlStr
      }
      this.getFixed()
    })
    // console.log(columns)
    // console.log(this.sortedColumns)
    // this.$refs.xTable.getColumns().forEach((v) => {
    //   console.log(v.property)
    // })
    // console.log(this.$refs.xTable.getColumns())

    if (localStorage.getItem("resultCols")) {
      const historyCols = JSON.parse(localStorage.getItem("resultCols"));
      const getColumns = this.$refs.xTable.getColumns()

          .reduce((colunms, item) => {
            if (!item.property) {
              colunms.push(item);
            }
            // if (historyCols.indexOf(item.property) >= 0) {
            //   colunms.push(item)
            //   console.log(historyCols)
            // }
            for (let i = 0; i < historyCols.length; i++) {
              if (historyCols[i] === item.property) {
                colunms.push(item);
              }
            }
            return colunms;
          }, []);
      const xTable = this.$refs.xTable;
      xTable.loadColumn(getColumns);
    }
  },
  beforeDestroy() {
    if (this.sortable) {
      this.sortable.destroy();
    }
  },
  methods: {
    /**
     * 循环的el-select 强制刷新视图
     */
    selectSet(index) {
      this.$set(this.right, index, this.right[index]);
    },
    batchAdd(func){
      this.batchAddFunc = func
    },
    /**
     * 显示头像
     */
    imgBtn() {
      const  select_row = this.selectRow
      if(!select_row) return this.$message.warning('请选择人员')
      if (select_row) {
        this.seen = !this.seen;
        this.showOverflow = !this.showOverflow;
        if (this.seen) {
          columns.push({
            fixed: "right",
            showOverflow: true,
            width: 120,
            slots: {default: "operated"},
          });
          const xTable = this.$refs.xTable;
          xTable.loadColumn(columns);
        } else {
          columns.pop();
          const xTable = this.$refs.xTable;
          xTable.loadColumn(columns);
        }
      }
    },
    //刷新
    refreshData() {
      this.fixedId ? this.getFixed(this.currentPage, 'update') : this.getList(this.currentPage, 'update')
    },
    //选中页数
    currentChange(e) {
      this.currentPage = e;
      this.fixedId ? this.getFixed(e) : this.getList(e)
    },
    // 拖拽开始
    onStart() {
      this.drag = true;
    },
    // 拖拽结束
    onEnd() {
      this.drag = false;
    },
    // 显示常用统计分析
    showCommonAnalyse() {
      this.getStatisticsList()
      this.statisticsList = []
      this.commonAnalyse = true;
      this.$nextTick(() => {
        this.$refs.statisticsTree.setCurrentKey(null);
      })
    },
    // 显示自定义统计分析
    showCustomAnalyse() {
      this.customAnalyse = true;
    },
    /**
     * 查询无头像人员
     */
    async noPhoto() {
      if (this.noPhotos) {
        this.photo = "";
      } else {
        this.photo = "abc";
      }
      this.noPhotos = !this.noPhotos;
      this.fixedId ? await this.getFixed() : await this.getList()
    },
    //重置下拉
    resetPersonnelStatus(e) {
      if(e) this.updateStatus = ''
    },
    /**
     * 批量修改人员状态
     */
    updatePersonnelStatus(e) {
      if(!this.personneluuids.length) {
        this.updateStatus = ''
        return this.$message.warning('请先选择人员')
      }
      if (this.personneluuids.length > 0 && e && e !== "暂无数据") {
        postAction(baseStaff.batchModificationPersonnelStatus, {
          personnelStatus: this.updateStatus,
          uuids: this.personneluuids,
        }).then((res) => {
          if (res.code === 200) {
            this.$message.success('操作成功!');
            this.fixedId ? this.getFixed() : this.getList()
          } else {
            this.$message.waring(res.msg);
          }
        });
      }
    },
    /** 批处理修改
     */
    handleModifyDialog() {
      this.batchValue = []
      this.fixedId ? this.getFixed() : this.getList()
    },
    /**
     * 选中的人员
     */
    selectPersonnel(e) {
      if (e.checked) {
        this.personneluuids.push(e.row.uuid);
      } else {
        this.personneluuids.splice(this.personneluuids.indexOf(e.row.uuid), 1);
      }
    },
    /**
     * 全选
     */
    allSelectPersonnel(e) {
      if (e.checked) {
        this.gridOptions.data.forEach((v) => {
          this.personneluuids.push(v.uuid);
        });
      } else {
        this.personneluuids = [];
        this.$store.commit("changeBaseCodes", []);
      }
    },
    /**
     * 批处理
     */
    batchProcessing(e) {
      const [ component , index ] = e
      const { personneluuids, subsetUuid } = this
      if (!personneluuids.length && index === 0){
        this.$message({
          type: "waring",
          message: "请选择要批处理的人员",
        });
        this.batchValue = []
        return
      }
      if(component === "AddChildren"){
        this.batchAddFunc(personneluuids.length != 0 ? personneluuids: this.gridOptions.data.map(i => i.uuid))
        return
      }
      switch (index) {
        case undefined:
          this.$refs[component][0].handleOpenDialog(this.gridOptions.data.map(i => i.uuid), subsetUuid)
          return
        case 0:
          this.$refs[component][0].handleOpenDialog(personneluuids, subsetUuid)
          return
        case 1:
          this.$refs[component][0].handleOpenDialog(this.gridOptions.data.map(i => i.uuid), subsetUuid,'查询出的')
          return
      }

    },
    /**
     * 获取树部门数据
     */
    async getDepartmentList() {
      const result = await getAction('/opDictNew/findTreeByType', { type:'rs_department' })
      if (result.code === 200) {
        this.allGroupList = result .data
      }
    },
    // 显示集体内排序
    showSort() {
      this.getDepartmentList()
      this.sortModal = true;
    },
    handleCheckAllChange(val) {
      this.checkedDelete = val ? deleteSubset : [];
      this.isIndeterminate = false;
    },
    handleCheckedCitiesChange(value) {
      const checkedCount = value.length;
      this.checkAll = checkedCount === this.deleteSubset.length;
      this.isIndeterminate =
          checkedCount > 0 && checkedCount < this.deleteSubset.length;
    },
    /**
     * 选择要批处理的子集
     */
    subsetBtnT() {
      if (
          (!this.isDeleteSubset && !this.selectSubset) ||
          (this.isDeleteSubset && !this.checkedDelete)
      ) {
        return;
      }
      if (this.isDeleteSubset) {
        for (let i = 0; i < this.checkedDelete.length; i++) {
          if (deleteSubset.indexOf(this.checkedDelete[i]) !== -1) {
            this.selectDelete.push(
                this.allSubset[deleteSubset.indexOf(this.checkedDelete[i])]
                    .tableName
            );
          }
        }
        const h = this.$createElement;
        this.$msgbox({
          title: "提示",
          message: h("p", null, [
            h("span", null, "是否要删除所选人员的当前子集信息 "),
          ]),
          showCancelButton: true,
          confirmButtonText: "确定",
          cancelButtonText: "取消",
        }).then((res) => {
          postAction(baseStaff.batchDeleteTableByUuids, {
            uuids: this.personneluuids,
            tableNames: this.selectDelete,
          }).then((res) => {
            if (res.code === 200) {
              this.$message({
                type: "success",
                message: "操作成功!",
              });
            } else {
              this.$message({
                type: "waring",
                message: res.msg,
              });
            }
          });
        });
        this.centerDialogVisible = false;
        this.batchValue = [];
        return;
      }

      this.$store.commit("changeBaseCodes", this.personneluuids);
      if (this.isUpdateSubset) {
        this.$store.commit("changeUpdateSubset", true);
      }
      switch (this.selectSubset) {
        case "OP_STAFF_DEGREE": // 学历及学位子集
          this.$store.commit("changeDegree", true);
          break;
        case "OP_SALARY_CHANGE": // 工资变动子集
          this.$store.commit("changeWageChange", true);
          break;
        case "OP_ADMINISTRATIVE_PARTY_POSITIONS": // 行政党派职务子集
          this.$store.commit("changeAdministrative", true);
          break;
        case "OP_POLITICAL_OUTLOOK": // 政治面貌及党籍情况子集
          this.$store.commit("changePolitical", true);
          break;
        case "OP_PROFESSIONAL_POSITION": // 专业技术职务子集
          this.$store.commit("changeTechnical", true);
          break;
        case "OP_TECHNICAL_LEVEL_WORKERS": // 工人技术等级子集
          this.$store.commit("changeWorkerLevel", true);
          break;
        case "OP_SALARY": // 工资子集
          this.$store.commit("changeWage", true);
          break;
        case "OP_POSITION": // 岗位信息子集
          this.$store.commit("changePosition", true);
          break;
        case "OP_SPECIAL_PROFESSIONAL_TEACH_PEOPLE": // 特殊人才子集
          this.$store.commit("changeSpecialTalents", true);
          this.$store.commit(
              "changeTableName",
              "OP_SPECIAL_PROFESSIONAL_TEACH_PEOPLE"
          );
          break;
        case "OP_STAFF_RESUME": // 个人简历子集
          this.$store.commit("changeResume", true);
          break;
        case "OP_PROFESSIONAL_QUALIFICATIONS": // 执(职)业资格子集
          this.$store.commit("changeOccupation", true);
          break;
        case "OP_EDUCATION_TRANINING": // 教育培训子集
          this.$store.commit("changeEducation", true);
          break;
        case "OP_REWARD": // 奖励(行政及党内)子集
          this.$store.commit("changeReward", true);
          break;
        case "OP_PARTY_PUNISHMENT": // 惩罚(行政及党内)子集
          this.$store.commit("changePenalty", true);
          break;
        case "OP_RELATION_WITH_ME": // 家庭成员及社会关系子集
          this.$store.commit("changeFamilySociety", true);
          break;
        case "OP_FLOW": // 流动情况子集
          this.$store.commit("changeLiquidity", true);
          break;
        case "OP_LABOR_CONTRACT_SIGNING": // 劳动合同签订情况子集
          this.$store.commit("changeLabor", true);
          break;
        case "OP_CADRE_ADJUST_EXCHANGE": // 干部调整与交流子集
          this.$store.commit("changeCadre", true);
          break;
        case "OP_RETIRE": // 离休退休子集
          this.$store.commit("changeRetirement", true);
          break;
        case "OP_ORGANIZATION_INVESTIGATION": // 组织考察(考核)子集
          this.$store.commit("changeInvestigation", true);
          break;
        case "OP_PART_TIME_JOB": // 兼任职务子集
          this.$store.commit("changeConcurrent", true);
          break;
        case "OP_GOING_ABROAD": // 出国(出境)子集
          this.$store.commit("changeGoingAbroad", true);
          break;
        default:
          console.log("首页");
      }
      this.centerDialogVisible = false;
      this.batchValue = [];
    },
    /**
     * 取消选择子集的按钮
     */
    subsetBtnF() {
      this.selectSubset = "";
      this.batchValue = [];
      this.selectDelete = [];
      this.centerDialogVisible = false;
      this.$store.commit("changeDegree", false);
    },
    async getList(page, type) {
      if (type === 'update') {
        this.clickRow = null
      }
      let self = this;
      this.VxeLoading = true
      const result = await postAction(baseStaff.baseStaffSearch, {
        size: 10,
        page: page ? page : 1,
        personnelStatus: this.personnelStatus, // 人员状态
        uuid: this.baseCode, // 人员uuid
        national: this.national, // 民族
        sex: this.sex, // 性别
        isNoPartyMember: this.isNoPartyMember, // 中共党员
        photo: this.photo, // 有无照片
        ageMax: this.ageMax, //最大年龄
        ageMin: this.ageMin,  //最小年龄
        degreeMax: this.degreeMax, //最高学历
        degreeMin: this.degreeMin, //最低学历
        departmentList: this.departmentList, //机构id 数组
        educationType: this.educationType, //全日制
        jobCategory: this.jobCategory, //职务类别
        positionLevel: this.positionLevel, //职务级别,
        dataEnd: this.dataEnd // 年龄截止
      });
      if (result.code === 200) {
        self.gridOptions.data = result.data.list;
        localStorage.setItem("person", JSON.stringify(result.data.list.map(obj => {
          return {id: obj.uuid, name: obj.name}
        })))
        self.pagerConfig.total = result.data.total;
      }
      this.VxeLoading = false

    },
    async getFixed(page, type) {
      if (type === 'update') {
        this.clickRow = null
      }
      this.VxeLoading = true
      let self = this
      const result = self.isFixedCondition ? await postAction(opCondition.search, {
        list: this.isFixedConditionList,
        sqlStr: this.isFixedConditionSql,
        size: 10,
        page: page ? page : 1
      }) : await postAction(opCondition.searchById, {
        uuid: self.fixedId,
        size: 10,
        page: page ? page : 1
      });
      if (result.code === 200) {
        self.gridOptions.data = result.data.list;
        self.pagerConfig.total = result.data.total;
      }
      this.VxeLoading = false
    },
    /**
     * 取消选择子集的按钮
     */
    handleTwoDimensional() {
      this.twoDimensional = true
      this.getFindByType()
    },
    /**
     * 二维统计列表
     */
    getFindByType() {
      getAction(opCount.findByType, { uuid: 'admin' }).then(res=> {
        if(res.code === 200) {
          this.erweiList = res.data
        }
      })
    },
    /**
     * 关闭二维统计
     */
    closeTwoDimensional() {
      this.erweiValue1 = ''
      this.erweiValue2 = ''
      this.twoDimensional = false
    },
    /**
     * 保存二维统计
     */
    saveTwoDimensional() {
      if (!this.erweiValue1 || !this.erweiValue2) return this.$message.warning({message: '请补全统计条件'})
      this.saveStatistics = true
    },
    /**
     * 二维统计
     */
    startTwoDimensional() {
      if (!this.erweiValue1 || !this.erweiValue2) return this.$message.warning({message: '请补全统计条件'})
      this.erweiTableTitle = ['']
      this.erweiTableData = []
      this.chartData.rows = []
      let uuids = []
      uuids.push(this.erweiValue1)
      uuids.push(this.erweiValue2)
      postAction(opCount.countByTwo, { uuids }).then(res=> {
        if(res.code === 200) {
          res.data[0].map(i=> {
            let item = [i.name.split("/")[1]]
            this.erweiTableData.push(item)
          })
          res.data.map(result => {
            this.erweiTableTitle.push(result[0].name.split("/")[0])
            result.map((item,item_index) => {
              this.erweiTableData[item_index].push(item.value)
              let rows_obj = {
                name: item.name,
                value: item.value
              }
              this.chartData.rows.push(rows_obj)
            })
          })
          this.erweiTable = true
        }
      })
    },
    //获取统计列表
    async getStatisticsList() {
      let self = this
      self.analyseData = [
        {
          uuid: 'null1',
          name: "基本信息类",
          type: 'file',
          children: []
        },
        {
          uuid: 'null2',
          name: "干部统计类",
          type: 'file',
          children: []
        },
        {
          uuid: 'null3',
          name: "其他类",
          type: 'file',
          children: []
        },
      ]
      const result = await getAction(opCount.findAll, {uuid: 'admin'});
      if (result.code === 200) {
        self.analyseData[0].children = result.data.basic
        self.analyseData[1].children = result.data.cadre
        self.analyseData[2].children = result.data.other
        self.analyseData.push(...result.data.root)
      }
    },
    //获取简单统计列表
    async getCustomStatisticsList() {
      let self = this
      const result = await postAction(baseStaffCount.getCustomStatisticsList);
      if (result.code === 200) {
        self.left = result.data;
      }
    },
    handleGeneralStatistics() {
      this.commonUse = true
      this.isEitstatistics = false
      this.statisticsList = []
    },
    /**
     * 单项统计计算
     */
    handleCalculation() {
      if (!this.checkedLeft.length) return this.$message.warning({message: '请选择一项'})
      postAction(opCount.countByOne, {
        date: this.time?this.formateDate(this.time): '',
        field: this.checkedLeft[0].fieldCode,
        type: this.radio
      }).then(res=> {
        if(res.code === 700) return this.$message.warning({message: '请选择正确计算类型'})
        if(res.code === 200) {
          this.easyNum = res.data.count
          this.easySum = res.data.value
        }
      })
    },
    /**
     * 常用统计分析树 编辑
     */
    treeEdit() {
      if (!this.$refs.statisticsTree.getCurrentNode()) return this.$message.warning({message: '请选择一项'})
      this.isEitstatisticsTree = true
      const eitItemTree = this.$refs.statisticsTree.getCurrentNode()
      this.saveStatisticsName = eitItemTree.name
      this.statisticsList = JSON.parse(eitItemTree.param)
      if(eitItemTree.type !== 2) {
        this.statisticsList.forEach((res, index) => {
          res.list.forEach((result, index_r) => {
            if(result.type === 'input' || result.type === 'radio' || result.type === 'date') {
              result.value = result.value.join(",")
            }
            if(result.type === 'number') {
              result.value = result.value[0]
            }
          })
        })
      }
      if(eitItemTree.type === 0) {
        this.easyStatistics = true
        this.right = []
        this.statisticsList[0].list.map((res,index) => {
          this.selectContentByNameTable(res.type, res.code.toLowerCase())
          let item_list = {
            description: this.statisticsList[0].name,
            fieldCode: res.code,
            fieldName: res.fieldName,
            type: res.type,
            operation: res.operation ? res.operation : '',
            value: res.value ? res.value : ''
          }
          this.right.push(item_list)
        })
      }else if(eitItemTree.type === 1) {
        this.commonUse = true
      }else if(eitItemTree.type === 2) {
        this.twoDimensional = true
        this.getFindByType()
        this.erweiValue1 = this.statisticsList[0]
        this.erweiValue2 = this.statisticsList[1]
      }
    },
    /**
     * 统计
     */
    handleStatistics() {
      if (!this.$refs.statisticsTree.getCurrentKey()
          || this.$refs.statisticsTree.getCurrentKey() === 'null1'
          || this.$refs.statisticsTree.getCurrentKey() === 'null2'
          || this.$refs.statisticsTree.getCurrentKey() === 'null3') return this.$message.warning({message: '请选择一个统计分布'})
      if(this.$refs.statisticsTree.getCurrentNode().type === 2) {
        postAction(opCount.countByTwoById, { uuid: this.$refs.statisticsTree.getCurrentNode().uuid }).then(res=> {
          if(res.code === 200) {
            this.erweiTableTitle = ['']
            this.erweiTableData = []
            this.chartData.rows = []
            res.data[0].map(i=> {
              let item = [i.name.split("/")[1]]
              this.erweiTableData.push(item)
            })
            res.data.map(result => {
              this.erweiTableTitle.push(result[0].name.split("/")[0])
              result.map((item,item_index) => {
                this.erweiTableData[item_index].push(item.value)
                let rows_obj = {
                  name: item.name,
                  value: item.value
                }
                this.chartData.rows.push(rows_obj)
              })
            })
            this.erweiTable = true
          }
        })
      }else{
        this.commonAnalysePic = true
        this.getStatistics()
      }
    },
    //关闭常用统计分析图表
    handleCommonly() {
      this.chartType = 0
    },
    /**
     * 条件统计
     */
    handleStatisticsCondition() {
      if (!this.statisticsList.length) return this.$message.warning({message: '请添加至少一个通用统计项'})
      let param = JSON.parse(JSON.stringify(this.statisticsList))
      this.statisticsList.map((res, index) => {
        res.list.map((result, index_r) => {
          if(typeof result.value === 'string') {
            param[index].list[index_r].value = result.value.split(",")
          }
          if(typeof result.value === 'number') {
            param[index].list[index_r].value = [result.value]
          }
          if(typeof result.value === 'object') {
            param[index].list[index_r].value = [this.formateDate(result.value)]
          }
        })
      })
      postAction(opCount.count, { param }).then(res=> {
        this.createUniversalCharts(res)
      })
    },
    /** 通用统计编辑按钮
     */
    handleEitItem() {
      if(this.activeLabel === -1) return this.$message.warning({message: '请选择一个通用统计项'})
      this.sqlValue = this.statisticsList[this.activeLabel].sqlStr
      this.statisticalName = this.statisticsList[this.activeLabel].name
      this.right = []
      this.statisticsList[this.activeLabel].list.map(res => {
        let item_list = {
          fieldCode: res.code,
          fieldName: res.fieldName,
          type: res.type,
          operation: res.operation ? res.operation : '',
          value: res.value ? res.value : ''
        }
        this.right.push(item_list)
        this.isEitstatistics = true
      })
      this.right.map((res,index) => {
        this.selectContentByNameTable(res.type, res.fieldCode.toLowerCase(),index)
      })
    },/** 通用统计删除按钮
     */
    handleDeteleItem() {
      if(this.activeLabel === -1) return this.$message.warning({message: '请选择一个通用统计项'})
      this.$confirm('是否要删除这条数据?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
          .then(() => {
            this.statisticsList.splice(this.activeLabel,1)
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消删除'
            })
          })
    },
    /** 简单统计Tab切换
     */
    handleEasyTab(index) {
      this.easyStatisticsTab = index
      this.easyStatisticsKey++
      this.handleEasy()
    },
    /**
     * 简单统计保存
     */
    handleSaveEasy() {
      if (!this.right.length) return this.$message.warning({message: '请添加至少一个统计项'})
      this.getStatisticsList()
      this.statisticsList = []
      this.right.map(res => {
        let item = {
          name: res.description,
          list: [],
          sqlStr: '@1'
        }
        const conditionObj = {
          code: res.fieldCode,
          fieldName: res.fieldName,
          type: res.type,
          operation: res.operation ? res.operation : '',
          value: res.value ? res.value : ''
        }
        item.list.push(conditionObj)
        this.statisticsList.push(item)
      })
      this.saveStatistics = true
    },
    //日期转化
    formateDate(data) {
      let year = data.getFullYear()
      let month = data.getMonth() + 1
      let day = data.getDate()
      let hh = data.getHours()
      let dd = data.getMinutes()
      let mm = data.getSeconds()
      if (month < 10) month = '0' + month
      if (day < 10) day = '0' + day
      if (hh < 10) hh = '0' + hh
      if (dd < 10) dd = '0' + dd
      if (mm < 10) mm = '0' + mm
      return year + '-' + month + '-' + day + " " + hh + ':' + dd + ':' + mm
    },
    /**
     * 简单统计
     */
    handleEasy() {
      if (!this.right.length) return this.$message.warning({message: '请添加至少一个统计项'})
      this.statisticsList = []
      this.right.map(res => {
        let item = {
          name: res.description,
          list: [],
          sqlStr: '@1'
        }
        const conditionObj = {
          code: res.fieldCode,
          fieldName: res.fieldName,
          type: res.type,
          operation: res.operation ? res.operation : '',
          value: res.value ? res.value : ''
        }
        item.list.push(conditionObj)
        this.statisticsList.push(item)
      })
      let param = JSON.parse(JSON.stringify(this.statisticsList))
      this.statisticsList.map((res, index) => {
        res.list.map((result, index_r) => {
          if(typeof result.value === 'string') {
            param[index].list[index_r].value = result.value.split(",")
          }
          if(typeof result.value === 'number') {
            param[index].list[index_r].value = [result.value]
          }
          if(typeof result.value === 'object') {
            param[index].list[index_r].value = [this.formateDate(result.value)]
          }
        })
      })
      postAction(opCount.count, { param }).then(res=> {
        this.createUniversalCharts(res)
      })
    },
    /**
     * 简单统计
     */
    simpleStatistics() {
      this.easyStatistics = true
      this.isEitstatistics = false
      this.statisticsList = []
    },
    /**
     * 创建通用统计图表
     */
    createUniversalCharts(result) {
      let self = this
      this.commonAnalysePic = true
      this.erweiTableTitle = []
      this.erweiTableData = []
      this.chartData.rows = []
      let item = {}
      result.data.map(res=> {
        let row_item = {
          name: res.name,
          value: res.value
        }
        this.chartData.rows.push(row_item)
        this.erweiTableTitle.push(res.name)
        this.$set(item,res.name,res.value)
      })
      this.erweiTableData.push(item)
    },
    /** 获取智能导入列表
     */
    getSmartImport() {
      getAction(OpPour.findAll).then(res => {
        if (res.code === 200) {
          this.smartImportList = res.data
        }
      })
    },
    /** 新增智能导入
     */
    handleSmart (type) {
      const select_item = this.$refs.smartImport.getCurrentNode()
      if(type === 'eit' && !select_item) return this.$message.warning('请选择编辑项')
      this.$prompt('请输入模板名称', `${type === 'add' ? '新增':'更改'}`, {
        inputValue:type === 'eit'?select_item.name: '',
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      }).then(({ value }) => {
        if(!value) return this.$message.warning('请输入模板名称')
        postAction(`/OpPour/${type === 'add'?'insert':'update'}`, {
          name: value ,
          baseCode: type === 'add'?'admin':select_item.baseCode,
          updateUser: type === 'add'?'admin':select_item.createUser,
          param: type === 'add'?this.headerCode:select_item.param,
          uuid: type === 'add'?'':select_item.uuid
        })
            .then((res) => {
              if (res.code === 200) {
                this.getSmartImport()
                this.$message.success(`${type === 'add' ? '保存成功':'更改成功'}`)
              }
            })
      })
    },
    /** 删除智能导入
     */
    handleDeleteSmart() {
      const select_item = this.$refs.smartImport.getCurrentNode()
      if(!select_item) return this.$message.warning('请选择删除项')
      this.$confirm('是否要删除这条数据?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
          .then(() => {
            postAction(OpPour.delete, { uuid: select_item.uuid })
                .then((res) => {
                  if (res.code === 200) {
                    this.getSmartImport()
                    this.$message.success('删除成功')
                  }
                })
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消删除'
            })
          })
    },
    //获取统计列表
    async getStatistics() {
      let self = this
      const result = await postAction(opCount.countById, {uuid: this.$refs.statisticsTree.getCurrentKey()});
      if (result.code === 200) {
        this.createUniversalCharts(result)
      }
    },
    /**
     * 常用统计分析树 删除
     */
    treeDel() {
      if (!this.$refs.statisticsTree.getCurrentNode()) return this.$message.warning({message: '请选择删除对象'})
      if (this.$refs.statisticsTree.getCurrentNode().type === 'file') return this.$message.warning({message: '请选择正确的删除对象'})
      this.$confirm('是否要删除这条数据?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
          .then(() => {
            postAction(opCount.delete, {uuid: this.$refs.statisticsTree.getCurrentNode().uuid})
                .then((res) => {
                  if (res.code === 200) {
                    this.$message({
                      type: 'success',
                      message: '删除成功!'
                    })
                    this.getStatisticsList()
                  } else {
                    this.$message({
                      type: 'warning',
                      message: res.msg
                    })
                  }
                })
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消删除'
            })
          })
    },
    /**
     * checkBox单选
     */
    singleChoice(i) {
      console.log(i)
      this.checkedRight = [];
      this.checkedRight.push(this.right[i]);
      this.sqlValue = (this.sqlValue + " @" + (i + 1)).replace(
          /(^\s*)|(\s*$)/g,
          ""
      );
    },
    /**
     * 构建sql查询
     */
    createSql(i) {
      if (i === 1) {
        this.sqlValue = (this.sqlValue + " 并且").replace(/(^\s*)|(\s*$)/g, "");
      } else if (i === 2) {
        this.sqlValue = (this.sqlValue + " 或者").replace(/(^\s*)|(\s*$)/g, "");
      } else if (i === 3) {
        this.sqlValue = (this.sqlValue + " (").replace(/(^\s*)|(\s*$)/g, "");
      } else {
        this.sqlValue = (this.sqlValue + ")").replace(/(^\s*)|(\s*$)/g, "");
      }
    },
    /**
     * 根据选中子集的uuid查询字段
     */
    selectSubsetUuid(e) {
      this.left = e.list
      // postAction("/opTableField/opTableFieldSearch", {tableUuid: e}).then(
      //     (res) => {
      //       if (res.code === 200) {
      //         this.left = res.data;
      //         console.log( this.left)
      //       }
      //     }
      // );
    },
    //数字类型判断
    leaveJudgment(index) {
      if (typeof this.right[index].value !== 'number') {
        this.right[index].value = ''
      }
    },
    //关闭智能导入
    closeExcel() {
      this.intelligence = false
      this.isTemplateImport = false
      this.ExcelName = ''
      this.selectTemplate = ''
      this.excelUpList = []
      this.excelKeys = []
      this.activeExcel = true
      this.excelIndexList = []
      this.excelFileList = []
      this.excelCommonlyList = []
      this.excelConstantList = []
      this.systemConstantList = []
      this.updateMethod = []
      this.headerCode = []
      this.table2Data = []
      this.table3Data = []
      this.checkedLeft = []
      this.checkedRight = []
      this.subsetUuid = ""
      this.active = 1
      this.smartRadio = '1'
      this.table2DelItem = null
    },
    /** 选择配置模板
     */
    handleSelect() {
      if(this.selectTemplate) { this.isTemplateImport = true }
    },
    /** 手动匹配
     */
    manualMatch() {
      if(!this.checkedLeft.length) return this.$message.warning('请选择Excel指标')
      if(!this.checkedRight.length) return this.$message.warning('请选择系统指标')
      if(this.table2Data.find(table_item => table_item.system === this.checkedRight[0].fieldName)) {
        this.$confirm('该常数已匹配过,若重新匹配，请先删除!', '提示', {
          confirmButtonText: '确定',
          type: 'warning'
        })
        return
      }
      this.$confirm(`是否匹配${this.checkedLeft[0].name}->${this.checkedRight[0].fieldName}?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
          .then(() => {
            const item = {
              excel: this.checkedLeft[0].name,
              system: this.checkedRight[0].fieldName,
              table: this.subsetUuid.name,
              code: this.checkedRight[0].fieldCode
            }
            this.table2Data.push(item)
            this.excelIndexList[this.excelIndexList.findIndex(res=>res.name===this.checkedLeft[0].name)].noIndex = true
            this.checkedLeft = []
            this.checkedRight = []
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消删除'
            })
          })
    },
    /** 手动匹配常数
     */
    constantMatch() {
      const excel_item = this.$refs.excelConstantList.getCurrentNode()
      const system_item = this.$refs.systemConstantList.getCurrentNode()
      if(!excel_item || !system_item) return this.$message.warning(`请选择${!excel_item?'Excel中常数值':'系统中常数值'}`)
      if(this.table3Data.find(table_item => table_item.systemName === system_item.name)) {
        this.$confirm('该常数已匹配过,若重新匹配，请先删除!', '提示', {
          confirmButtonText: '确定',
          type: 'warning'
        })
        return
      }
      this.$confirm(`是否匹配${excel_item.name}->${system_item.name}?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
          .then(() => {
            const item = {
              excelName: excel_item.name,
              systemName: system_item.name,
              systemUUid: system_item.uuid
            }
            this.table3Data.push(item)
            this.$refs.excelConstantList.setCurrentKey(null)
            this.$refs.systemConstantList.setCurrentKey(null)
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消删除'
            })
          })
    },
    /** 智能匹配常数
     */
    smartConstantCurrent() {
      if(!this.checkedLeft.length) return this.$message.warning('请选择Excel中指标')
      this.systemConstantList && this.systemConstantList.map(res => {
        const item = this.excelConstantList.find(result => result.name === res.name)
        if (item) {
          const item2 = {
            excelName: item.name,
            systemName: res.name,
            systemUUid: res.uuid
          }
          if(!this.table3Data.length || !this.table3Data.find(table_item => table_item.systemName === item2.systemName)) {
            this.table3Data.push(item2)
          }
        }
      })
    },
    /** 智能匹配当前集
     */
    smartMatchingCurrent() {
      if(!this.subsetUuid) return this.$message.warning('请选择系统指标集')
      this.excelIndexList.forEach(res => {
        const item = this.left.find(result => result.fieldName === res.name)
       if (item) {
         const item2 = {
           excel: res.name,
           system: item.fieldName,
           table: this.subsetUuid.name,
           type: item.type,
           code: item.code
         }
         if(!this.table2Data.length || !this.table2Data.find(table_item => table_item.system === item2.system)) {
           this.table2Data.push(item2)
           res.noIndex = true
           if(item.type === 'radio' || item.type === 'tree') {
             this.excelCommonlyList.push(item)
           }
         }
       }
      })
    },
    /** 智能匹配所有集
     */
    smartMatchingAll() {
      let array_all_sub = []
      let copy_all_subset = JSON.parse(JSON.stringify(this.allSubset))
      copy_all_subset.forEach(res=> {
        res.list.length ? res.list.forEach(result => result.tableName = res.name) : ''
      })
      copy_all_subset.map(sub_item => array_all_sub = array_all_sub.concat(sub_item.list))
      this.excelIndexList.map(res => {
        const item = array_all_sub.find(result => result.fieldName === res.name)
        if (item) {
          const item2 = {
            excel: res.name,
            system: item.fieldName,
            table: item.tableName,
            type: item.type,
            code: item.fieldCode
          }
          if(!this.table2Data.length || !this.table2Data.find(table_item => table_item.system === item2.system)) {
            this.table2Data.push(item2)
            res.noIndex = true
            if(item.type === 'radio' || item.type === 'tree') {
              this.excelCommonlyList.push(item)
            }
          }
        }
      })
    },
    /** 数据导入
     */
    handleDataImport() {
      if(!this.ExcelName) return this.$message.warning('请导入Excel文件')
      if(this.excelIndexList.find(res=>res.name === '__EMPTY')) return this.$message.error('导入失败,请检查上传文件于开始行号是否匹配')
      postAction(queryCondition.fieldList, { list: this.selectTemplate.param }).then(res=> {
        if(res.code === 200) {
          const data_List = res.data
          this.headerCode = data_List.reduce((cur,item)=>cur.concat(item.fieldCode),[])
          this.excelIndexList.forEach(result => {
            const find_item = data_List.find(item_list => item_list.fieldName === result.name) //匹配找到都有的常量
            if(find_item) {
              result.noIndex = true
              if(find_item.type === 'radio' || find_item.type === 'tree') { //根据常量type确定调用接口
                getAction(`/opDictNew/${find_item.type === 'radio'?'findByType':'findTreeByType'}`, {
                  type: find_item.dict
                }).then(real=>{
                  const dictionary = real.data //返回类似数据字典如[{name: '男'，id: '1'}]
                  let stop_for = this.excelUpList.map(y=>{
                    const stopFor = this.recursiveDictionary(dictionary,y,find_item)  //递归调换this.excelUpList能匹配到的字典id
                     if(stopFor) return stopFor
                  })
                  if(!stop_for.includes(true)) { this.active = 5 } //若返回数组中有true则不跳转
                })
              }
            }
          })
        }
      })
    },
    /** 递归字典
     */
    recursiveDictionary(dictionary,y,find_item) {
      for (let res in dictionary) {
        if(dictionary[res].name === y[find_item.fieldName]) {
          y[find_item.fieldName] = dictionary[res].uuid
          break; //匹配到终止循环
        }else{
          if(dictionary[res].child) {
            this.recursiveDictionary(dictionary[res].child,y,find_item) //递归
          }
          if(res == dictionary.length -1) {
            const err_dictionary = true
            this.$message.error(`请正确填写Excel表${find_item.fieldName}列的数据`) //找到最后一个还未匹配到则返回错误
            return err_dictionary
          }
        }
      }
    },
    /** 下一步
     */
    next() {
      if(this.active === 1) {
        if(!this.ExcelName) return this.$message.warning('请导入Excel文件')
        if(this.excelIndexList.find(res=>res.name === '__EMPTY')) return this.$message.error('导入失败,请检查上传文件于开始行号是否匹配')
      }
      if(this.active === 2) {
        if(!this.table2Data.length) return this.$message.warning('请进行指标匹配')
        if(this.excelIndexList.find(res=> !res.noIndex)) {
          this.$confirm('指标未全部匹配,您确认要下一步吗?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          })
              .then(() => {
                this.checkedLeft = []
                this.checkedRight = []
                this.active ++
              })
              .catch(() => {

              })
        }
        return
      }
      if(this.active === 3 ) {
        this.headerCode = this.table2Data.reduce((cur,item) => cur.concat(item.code),[])
        let stop_for = this.excelUpList.length && this.excelUpList.map(res => {
          let stopFor = this.excelCommonlyList.map(result => {
            const key =  this.excelIndexList.length && this.excelIndexList.find( i => i.name === result.fieldName)
            const common_item = key && this.table3Data.find(y => y.systemName === res[key.name] )
            if(!common_item) {
              const err_dictionary = true
              return err_dictionary
            }
            res[key.name] =  common_item.systemUUid
          })
          return stopFor
        })
        let unfold_stop_for = []
        unfold_stop_for = unfold_stop_for.concat(...stop_for)
        if(unfold_stop_for.concat().includes(true)) return this.$message.error('请匹配Excel中指标的所有数据')
      }
      this.checkedLeft = []
      this.checkedRight = []
      this.active ++
    },
    //开始行号数字类型判断
    leaveLineJudgment(index) {
      if (typeof this.startLineNumber !== 'number') {
        this.startLineNumber = 1
      }
    },
    /**
     * 依据字典name查下拉选或依据表名table查树状所有的数据
     */
    selectContentByNameTable(type, dict,index) {
      const successFun = (res)=> {
        this.intelligence ? this.systemConstantList = res.data : this.$set(this.right[index], 'inquire', res.data)
      }
      getAction(`/opDictNew/${type === 'radio'?'findByType':'findTreeByType'}`, { type: dict}).then(res => {
        successFun(res)
      })
    },
    /**
     * 右箭头
     */
    toRight() {
      if (this.easyStatistics) {
        // 简单统计dialog
        if (!this.checkedLeft.length) return this.$message.warning({message: '请选择一个选项'})
        let sameArray = this.right.filter(res => res.fieldCode === this.checkedLeft[0].fieldCode)
        if (this.checkedLeft.length === 1 && (sameArray.length || !this.right.length)) {
          // this.right = this.handleConcatArr(this.right, this.checkedLeft);
          this.right.push(JSON.parse(JSON.stringify(this.checkedLeft[0])))
          this.right[this.right.length - 1].num = this.right.length - 1
        } else {
          this.$message({
            type: "waring",
            message: "只允许添加同一指标",
          });
        }
      } else {
        if (!this.checkedLeft.length) return this.$message.warning({message: '请选择一个选项'})
        // this.right = this.handleConcatArr(this.right, this.checkedLeft);
        this.right.push(JSON.parse(JSON.stringify(this.checkedLeft[0])))
        this.right[this.right.length - 1].num = this.right.length - 1
      }

      if (this.right[this.right.length - 1].type === 'radio' || this.right[this.right.length - 1].type === 'tree') {
        this.selectContentByNameTable(this.right[this.right.length - 1].type, this.right[this.right.length - 1].dict)
      }
    },
    /**
     * 左箭头
     */
    toLeft() {
      let list = [];
      for (const item of this.checkedRight) {
        if (this.right[item]) {
          list.push(this.right[item]);
        } else {
          list.push(item);
        }
      }
      this.right = this.right.concat(list).filter((v, i, arr) => {
        return arr.indexOf(v) === arr.lastIndexOf(v);
      })
      this.checkedRight = [];
    },
    handleConcatArr(selectArr, nowSelectData) {
      let arr = [];
      arr = arr.concat(selectArr, nowSelectData);
      return arr;
    },
    //选中table2的行
    handleTable2Data(e) {
      this.table2DelItem = e
    },
    //选中table3的行
    handleTable3Data(e) {
      this.table3DelItem = e
    },
    /** 智能导入删除单个
     */
    delSelectTable() {
      if(!this.table2DelItem) return this.$message.warning('请选择删除项')
      const  index = this.table2Data.findIndex(res => res.fieldName === this.table2DelItem.name)
      this.table2Data.splice(index , 1)
      this.table2DelItem = null
    },
    /** 智能导入常数删除单个
     */
    delSelectTable3() {
      if(!this.table3DelItem) return this.$message.warning('请选择删除项')
      const  index = this.table3Data.findIndex(res => res === this.table3DelItem)
      this.table3Data.splice(index , 1)
      this.table3DelItem = null
    },
    /**
     * 删除全部
     */
    delAll() {
      this.$confirm('是否全部删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
          .then(() => {
            if(this.active === 2) {this.table2Data = []}
            if(this.active === 3) {this.table3Data = []}
            this.checkedLeft = []
            this.checkedRight = []
            this.subsetUuid = ""
            this.left = [];
            this.right = [];
            this.statisticalName = ''
            this.sqlValue = ''
            this.table2DelItem = null
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消删除'
            })
          })
    },
    /**
     * 只允许选择一个字段
     */
    handleLeftCheckbox(e) {
      this.time = ''
      this.radio = 'SUM'
      if (this.checkedLeft.length > 1) {
        this.checkedLeft.splice(0, 1);
      }
      if (this.individual) {
        // 单项统计dialog
        if (
            this.checkedLeft.length && this.checkedLeft[0].type === "date") {
          this.timeSetting = true;
        } else {
          this.timeSetting = false;
        }
      }
      this.simpleCountList = e
      if(this.intelligence) {
        this.excelConstantList = []
        this.systemConstantList = []
        if(e.length) {
          this.excelFileList.map(res => {
            const item = { name: res[e[0].fieldName] }
            this.excelConstantList.push(item)
          })
          this.selectContentByNameTable(e[0].type,e[0].dict)
        }
      }
      console.log(e)
    },
    /**
     * 只允许选择一个字段(右）
     */
    handleRightCheckbox(e) {
      this.time = ''
      this.radio = 'SUM'
      if (this.checkedRight.length > 1) {
        this.checkedRight.splice(0, 1);
      }
      if (this.individual) {
        // 单项统计dialog
        if (
            this.checkedRight.length && this.checkedRight[0].type === "date") {
          this.timeSetting = true;
        } else {
          this.timeSetting = false;
        }
      }
      this.simpleCountList = e
    },
    /** 开始导入
     */
    handleStartImport() {
      const table_list = []
      if(this.activeExcel) {
        this.excelKeys = []
        this.excelKeys = this.excelIndexList.reduce((cur,item) => item.noIndex ? cur.concat(item.name) : cur,[])
        this.activeExcel = false
      }
      this.excelUpList.map(res => table_list.push(this.excelKeys.reduce((cur,item) =>res[item]?cur.concat(res[item]):cur,[])))
      if(table_list[0].length !== this.headerCode.length) return this.$message.error(`Excel缺少模板信息`)
      const is_clear = this.updateMethod.includes('empty')
      const is_clear_child = this.updateMethod.includes('more')
      postAction(OpPour.pour, {
        clear: is_clear ? 1 : 0,
        clearChild: is_clear && is_clear_child ? 1 : 0,
        mode: Number(this.smartRadio),
        header: this.headerCode,
        table: table_list,
        createUser: 'admin'
      }).then(res => {
        if(res.code === 700) {
          const err = /(?<=\[).+?(?=\])/.exec(res.msg)[0]
          const err_message = err === 'DEPARTMENT'? '部门名称': err === 'SEX' ? '性别' : ''
          this.$message.error(`导入失败,缺少${err_message}信息`)
        }
        if(res.code === 200) {
          this.disabledBrowse = true
          this.$message.success('导入成功')
        }
      })
    },
    /**
     * 清空dialog的数据
     */
    clearDialog(val) {
      if (!val) {
        this.left = [];
        this.right = [];
        this.subsetUuid = "";
        this.checkedLeft = [];
        this.checkedRight = [];
        this.timeSetting = false;
        this.sqlValue = "";
        this.statisticalName = "";
        this.radio = 'SUM';
        this.time = "";
        this.operation = "";
      }
    },
    /**
     * 确定统计条件
     */
    confirmationCondition() {
      if (!this.statisticalName) return this.$message.warning({message: '请填写常用统计名称'})
      if (!this.sqlValue) return this.$message.warning({message: '请输入公式表达式'})
      let item = {
        name: this.statisticalName,
        list: [],
        sqlStr: this.sqlValue
      }
      this.right.map(res => {
        const conditionObj = {
          code: res.fieldCode,
          fieldName: res.fieldName,
          type: res.type,
          operation: res.operation ? res.operation : '',
          value: res.value ? res.value : ''
        }
        item.list.push(conditionObj)
      })
      if(this.isEitstatistics) {
        this.$set(this.statisticsList,this.activeLabel,item)
        this.isEitstatistics = false
        this.$message.success({message: '更改成功'})
      }else{
        this.statisticsList.push(item)
        this.$message.success({message: '添加成功'})
      }
    },
    /**
     * 选择统计条件
     */
    handleCheckStatistics(item, index) {
      this.activeLabel = index
    },
    /**
     * 双击编辑统计条件
     */
    handleStatisticsEit(item, index) {
      this.sqlValue = item.sqlStr
      this.statisticalName = item.name
      this.right = []
      item.list.map(res => {
        let item_list = {
          fieldCode: res.code,
          fieldName: res.fieldName,
          type: res.type,
          operation: res.operation ? res.operation : '',
          value: res.value ? res.value : ''
        }
        this.right.push(item_list)
        this.isEitstatistics = true
      })
      this.right.map((res,index) => {
        this.selectContentByNameTable(res.type, res.fieldCode.toLowerCase(),index)
      })
    },
    /**
     * 保存通用统计
     */
    handleSaveStatistics() {
      if (!this.statisticsList.length) return this.$message.warning({message: '至少确认一条常用统计'})
      this.getStatisticsList()
      this.saveStatistics = true
    },
    /**
     * 通用统计弹框
     */
    handleStatisticsBox() {
      this.saveStatistics = false
      this.saveStatisticsName = ''
      this.$nextTick(() => {
        this.$refs.saveStatistics.setCurrentKey(null);
      })
    },
    /**
     * 关闭通用统计树
     */
    handleStatisticsTree() {
      this.commonUse = false
      this.isEitstatisticsTree = false
      this.activeLabel = -1
    },
    /**
     * 确认保存
     */
    handleConfirm() {
      if (!this.saveStatisticsName) return this.$message.warning({message: '请输入名称'})
      let param = JSON.parse(JSON.stringify(this.statisticsList))
      if(this.twoDimensional) {
        param = []
        param.push(this.erweiValue1,this.erweiValue2)
      }else{
        this.statisticsList.map((res, index) => {
          res.list.map((result, index_r) => {
            if(typeof result.value === 'string') {
              param[index].list[index_r].value = result.value.split(",")
            }
            if(typeof result.value === 'number') {
              param[index].list[index_r].value = [result.value]
            }
            if(typeof result.value === 'object') {
              param[index].list[index_r].value = [this.formateDate(result.value)]
            }
          })
        })
      }
      if(this.isEitstatisticsTree) {
        postAction(opCount.update, {
          name: this.saveStatisticsName,
          param: JSON.stringify(param),
          type: this.easyStatistics?'0':this.commonUse?'1':this.twoDimensional?'2':'3',
          folder: this.$refs.statisticsTree.getCurrentNode().folder,
          baseCode: 'admin',
          updateUser: 'admin',
          uuid: this.$refs.statisticsTree.getCurrentNode().uuid
        }).then((res) => {
          if (res.code === 200) {
            this.saveStatisticsName = ''
            this.getStatisticsList()
            this.$message.success({message: '更改成功'})
          }
        })
        this.isEitstatisticsTree = false
      }else{
        postAction(opCount.add, {
          name: this.saveStatisticsName,
          param: JSON.stringify(param),
          type: this.easyStatistics?'0':this.commonUse?'1':this.twoDimensional?'2':'3',
          folder: !this.$refs.saveStatistics.getCurrentNode() ? '0' :
              this.$refs.saveStatistics.getCurrentNode().uuid === 'null1' ? '1' :
                  this.$refs.saveStatistics.getCurrentNode().uuid === 'null2' ? '2' :
                      this.$refs.saveStatistics.getCurrentNode().uuid === 'null3' ? '3' : '0',
          baseCode: 'admin',
          createUser: 'admin'
        }).then((res) => {
          if (res.code === 200) {
            this.saveStatisticsName = ''
            this.getStatisticsList()
            this.$message.success({message: '保存成功'})
          }
        });
      }
    },
    /**
     * 确认删除统计项
     */
    handleDeleteStatistics() {
      if (!this.$refs.saveStatistics.getCurrentNode()) return this.$message.warning({message: '请选择删除对象'})
      if (this.$refs.saveStatistics.getCurrentNode().type === 'file') return this.$message.warning({message: '请选择正确的删除对象'})
      this.$confirm('是否要删除这条数据?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
          .then(() => {
            postAction(opCount.delete, {uuid: this.$refs.saveStatistics.getCurrentNode().uuid})
                .then((res) => {
                  if (res.code === 200) {
                    this.$message({
                      type: 'success',
                      message: '删除成功!'
                    })
                    this.getStatisticsList()
                  } else {
                    this.$message({
                      type: 'warning',
                      message: res.msg
                    })
                  }
                })
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消删除'
            })
          })
    },
    /**
     * 鼠标右键
     */
    handleMouseDown(item, index, e) {
      e.preventDefault()
      console.log(1)
    },
    /**
     * 数据导入 Excel上传
     */
    beforeUpload(file) {
      if (!/\.(xlsx|xls|XLSX|XLS)$/.test(file.name)) {
        this.$message({
          type: "warning",
          message: "上传文件只能为excel文件，且为xlsx,xls格式!",
        });
        return false;
      }
      this.ExcelName = file.name;
    },
    //重新解析excel表格
    reselectExcel(content) {
      this.importExcel(content)
    },
    //获取excel表格并解析
    importExcel (content) {
      if(this.active === 1) { this.activeExcel = true }
      if(this.active === 5) { this.activeExcel = false }
      this.excelFile = content
      const file = content.file
      // let file = file.files[0] // 使用传统的input方法需要加上这一步
      this.file2Xce(file).then(tabJson => {
        if (tabJson && tabJson.length > 0) {
          this.xlsxJson = tabJson
          this.excelFileList = this.xlsxJson[0].sheet
          this.excelUpList = JSON.parse(JSON.stringify(this.excelFileList))
          this.excelIndexList = []
              Object.keys(this.excelFileList[0]).map(res => {
            const item = { name: res }
            this.excelIndexList.push(item)
          })
        }
      })
    },
    file2Xce (file) {
      let self = this
      return new Promise(function (resolve, reject) {
        const reader = new FileReader()
        reader.onload = function (e) {
          const data = e.target.result
          this.wb = XLSX.read(data, {
            type: 'binary'
          })
          const result = []
          let xlsxLth = this.wb.Sheets[this.wb.SheetNames[0]]["!ref"];
          let stopX = xlsxLth.substr(xlsxLth.indexOf(':')+1,this.wb.Sheets[this.wb.SheetNames[0]]["!ref"].length);
          this.wb.Sheets[this.wb.SheetNames[0]]["!ref"] = "A"+self.startLineNumber+":"+stopX
          this.wb.SheetNames.forEach((sheetName) => {
            result.push({
              sheetName: sheetName,
              sheet: XLSX.utils.sheet_to_json(this.wb.Sheets[sheetName])
            })
          })
          resolve(result)
        }
        // reader.readAsBinaryString(file.raw)
        reader.readAsBinaryString(file) // 传统input方法
      })
    },
    add() {
      this.clickRow = {};
      this.isEit = false;
      this.showModal = !this.showModal;
    },
    changeShowModal() {
      this.showModal = !this.showModal;
    },
    /** 编辑图片
     */
    editImg() {
      this.eitPhoto = true
      this.imageUrl = this.selectRow.photo
    },
    /** 上传图片
     */
    handleUpPhoto() {
      const formData = JSON.parse(JSON.stringify(this.selectRow))
      formData.photo = this.imageUrl
      postAction(baseStaff.update, formData).then((res) => {
        this.$message.success({message: '更新成功!'})
        this.upData()
        this.imgBtn()
      })
    },
    /** 关闭编辑照片
     */
    handleCloseDialog() {
      this.eitPhoto = false
    },
    handleAvatarSuccess (res, file) {
      // this.form.photo = res.data
      this.imageUrl = `${window.serverUrl.url}/${res.data}`
    },
    beforeAvatarUpload (file) {
      const isJPG = file.type === 'image/jpeg'
      const isLt2M = file.size / 1024 / 1024 < 2.5

      if (!isJPG) {
        this.$message.error('上传头像图片只能是 JPG 格式!')
      }
      if (!isLt2M) {
        this.$message.error('上传头像图片大小不能超过 2.5MB!')
      }
      return isJPG && isLt2M
    },
    currentChangeEvent({row}) {
      this.selectRow = row;
      this.eitPhotoTitle = `编辑照片——【${this.selectRow.name}】`
      this.clickRow = row;
      this.showImg = row.photo;
      this.$store.commit("changeBaseCode", row.uuid);
      this.$store.commit("changeBaseName", row.name);
    },
    clearCurrentRowEvent() {
      this.selectRow = null;
      this.$refs.xTable.clearRadioRow();
      this.$refs.xTable.clearCurrentRow();
    },
    handleClick({row}) {
      if (row) {
        this.clickRow = row
        this.eitPhotoTitle = `编辑照片——【${this.selectRow.name}】`
      };
    },
    handleDetails({row}) {
      if (row) this.clickRow = row;
      if (this.clickRow === null) return this.$message.warning({message: '请选择编辑对象'})
      this.isEit = true;
      this.showModal = !this.showModal;
    },
    handleDelete() {
      if (this.clickRow === null) return this.$message.warning({message: '请选择删除对象'})
      this.$confirm('是否要删除这条数据?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
          .then(() => {
            postAction(baseStaff.delete, {uuids: [this.clickRow.uuid]})
                .then((res) => {
                  if (res.code === 200) {
                    this.fixedId ? this.getFixed() : this.getList()
                    this.$message({
                      type: 'success',
                      message: '删除成功!'
                    })
                    this.clickRow = null
                  } else {
                    this.$message({
                      type: 'warning',
                      message: res.msg
                    })
                  }
                })
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消删除'
            })
          })
    },
    upData() {
      this.fixedId ? this.getFixed(this.currentPage, 'update') : this.getList(this.currentPage, 'update')
    },
    columnDrop() {
      this.$nextTick(() => {
        const xTable = this.$refs.xTable;
        this.sortable = Sortable.create(
            xTable.$el.querySelector(
                ".body--wrapper>.vxe-table--header .vxe-header--row"
            ),
            {
              handle: ".vxe-header--column:not(.col--fixed)",
              onEnd: ({item, newIndex, oldIndex}) => {
                const {fullColumn, tableColumn} = xTable.getTableColumn();
                const targetThElem = item;
                const wrapperElem = targetThElem.parentNode;
                const newColumn = fullColumn[newIndex];
                if (newColumn.fixed) {
                  // 错误的移动
                  if (newIndex > oldIndex) {
                    wrapperElem.insertBefore(
                        targetThElem,
                        wrapperElem.children[oldIndex]
                    );
                  } else {
                    wrapperElem.insertBefore(
                        wrapperElem.children[oldIndex],
                        targetThElem
                    );
                  }
                  return this.$XModal.message({
                    message: "固定列不允许拖动！",
                    status: "error",
                  });
                }
                // 转换真实索引
                const oldColumnIndex = xTable.getColumnIndex(
                    tableColumn[oldIndex]
                );
                const newColumnIndex = xTable.getColumnIndex(
                    tableColumn[newIndex]
                );
                // 移动到目标列
                const currRow = fullColumn.splice(oldColumnIndex, 1)[0];
                fullColumn.splice(newColumnIndex, 0, currRow);

                // 遍历获取重新排序后的序号
                this.sortedColumns = fullColumn.reduce((columns, item) => {
                  if (item.property) {
                    columns.push(item.property);
                  }
                  return columns;
                }, []);

                this.toolbarCustomEvent();
                xTable.loadColumn(fullColumn);
              },
            }
        );
      });
    },
    toolbarCustomEvent(event) {
      // console.log(event)
      if (
          (event && event.type === "open") ||
          (event && event.type === "close")
      ) {
        return false;
      }
      if (event && event.type === "reset") {
        const xTable = this.$refs.xTable;
        xTable.loadColumn(columns);
        this.getList();
        localStorage.removeItem("resultCols");
        return false;
      }
      const cols = this.$refs.xTable.getColumns().reduce((columns, column) => {
        if (column.property) {
          columns.push(column.property);
        }
        return columns;
      }, []);

      const resultCols = this.sortedColumns.reduce((total, item) => {
        if (cols.indexOf(item) >= 0) {
          total.push(item);
        }
        return total;
      }, []);

      localStorage.setItem("resultCols", JSON.stringify(resultCols));
    },

    /*
     * 获取人员状态字典
     */
    async getPersonnelStatus() {
      const result = await getAction("/opDictItem/getDictItemListByCode", {
        code: "personnel_status",
      });
      this.PersonnelStatus = JSON.parse(JSON.stringify(result.data.list));
      this.PersonnelLib = JSON.parse(JSON.stringify(result.data.list)); // 数据导入用
      this.getStatus = this.PersonnelLib[0].uuid;
      for (let i = 0; i < this.PersonnelStatus.length; i++) {
        this.PersonnelStatus[i].itemText =
            "转【" + this.PersonnelStatus[i].itemText + "】库";
        this.PersonnelStatus[i].itemValue === '1' ? this.PersonnelStatus[i].disabled = true : ''
      }
    },

    /*
     * 获取所有表的子集
     */
    async getSubset() {
      const result = await getAction(queryCondition.conditionsList);
      if (result.code === 200) {
        this.allSubset = result.data
        this.deleteSubset = result.data
        for (let i = 0; i < result.data.length; i++) {
          deleteSubset.push(result.data[i].name);
        }
      }
      // this.PersonnelStatus = result.data.list
      // for (let i = 0; i < this.PersonnelStatus.length; i++) {
      //   this.PersonnelStatus[i].itemText = '转【' + this.PersonnelStatus[i].itemText + '】库'
      // }
      // this.PersonnelStatus.unshift({
      //   uuid: '123',
      //   itemText: '移动'
      // })
    },
    async test() {
      let str = "哲学类，马克思主义理论类"
      str = str.split("，");
      for (let i of str) {
        await postAction(opDictNew.add, {
          "name": i,
          "type": "subject_list",
          "createUser": "admin",
          "baseCode": "022ed0203e4c4942b56ae9d8768b920a"
        })
      }
    },
  },
};
</script>
<style scoped lang="less">
@import "./bootstrap.min.css";

.table_tools {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
}

.box-class {
  margin: 1%;
  width: 48%;
  height: 48%;
  padding: 10px;
  text-align: center;
  border: 1px solid #cdcdcd;
  border-radius: 5px;
  cursor: pointer;
}

.field-class {
  width: 100%;
  text-align: left !important;
  margin-left: 0 !important;
}

.col_h_b {
  height: 400px;
  border: 1px solid #eee;
  border-radius: 5px;
  margin-top: 10px;
  overflow-y: auto;
  padding-left: 10px;
}

.line_h {
  line-height: 30px;
}

.text_one_row {
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.department-tree /deep/ .el-tree-node {
  .is-leaf + .el-checkbox .el-checkbox__inner {
    display: inline-block;
  }

  .el-checkbox__input > .el-checkbox__inner {
    display: none;
  }
}

.individual_line {
  border: 1px solid #eee;
  padding-left: 30px;
  position: relative;
  margin-top: 20px;
  height: 112px;
  display: flex;
  align-items: center;
}

.individual_title {
  display: inline-block;
  background: #fff;
  position: absolute;
  padding: 0 5px;
  top: -12px;
  left: 15px;
  font-weight: 600;
  color: #15428b;
  letter-spacing: 1px;
}

.erwei_title {
  text-align: center;
  line-height: 30px;
  font-weight: 600;
}

.erwei_chart {
  height: 200px;
  background: #ccffff;
  color: #cc0000;
  line-height: 200px;
  text-align: center;
  border: 1px dashed #666;
}

.chart_head {
  float: right;

  span {
    display: inline-block;
    padding: 0 10px;
    cursor: pointer;
    border-right: 1px solid #ccc;
    box-sizing: border-box;
  }
}
.text-center {
  text-align: center;
}
.dialogClass /deep/ .el-dialog__body {
  padding: 15px 20px 30px;
}

.active_label {
  line-height: 25px;
  cursor: pointer
}

.active_label:hover {
  background-color: rgb(238, 238, 238);
}

.active_label_active {
  background-color: rgb(217, 232, 251);
  color: rgb(204, 0, 102);
}
.avatar-uploader {
  border-radius: 6px;
  cursor: pointer;
  position: relative;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  border: 1px dashed #d9d9d9;
  border-radius: 3px;
  font-size: 28px;
  color: #8c939d;
  z-index: 999;
  width: 108px;
  height: 108px;
  line-height: 108px !important;
}
.avatar {
  z-index: 999;
  border: 1px dashed #d9d9d9;
  width: 108px;
  height: 108px;
  display: block;
}
::v-deep .text-center .we-button {
  margin-right: 0 !important;
}
.tableBox {
  th {
    padding: 0 !important;
    height: 30px;
    line-height: 30px;
  }

  td {
    padding: 0 !important;
    height: 30px;
    line-height: 30px;
  }
}

.intelligence_span {
  display: inline-block;
  padding: 0 5px;
}

.active_title {
  position: relative;
  background: #fff;
  color: #000;
  padding: 0 5px;
  left: 10px;
  font-weight: 700;
  top: 12px;
}

::v-deep .right-label .el-checkbox__label {
  width: 110px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

::v-deep .el-cascader {
  line-height: 29px;
}

::v-deep .el-input__icon {
  line-height: 29px;
}

::v-deep .el-cascader .el-input .el-input__inner {
  height: 29px;
  line-height: 29px;
}

.active_box {
  text-align: center;
  border: 1px solid #eee;
  padding: 25px 0 20px;
  height: 75px;
}
</style>
<style>
.vxe-body--column {
  line-height: 30px !important;
}

.vxe-custom--option .vxe-checkbox--icon {
  top: 0 !important;
}

.sortable-column-demo .vxe-header--row .vxe-header--column.sortable-ghost,
.sortable-column-demo .vxe-header--row .vxe-header--column.sortable-chosen {
  background-color: #dfecfb;
}

.vxe-table--render-default .vxe-body--column.col--ellipsis > .vxe-cell {
  height: auto !important;
}

.vxe-table--render-default
.vxe-body--column.col--ellipsis:not(.col--actived)
> .vxe-cell {
  max-height: 100% !important;
}

.select_search {
  display: flex;
  justify-content: space-between;
}

.custom-dialog {
  width: 800px;
}

.custom-dialog-half {
  width: 400px;
  min-height: 400px;
}
</style>
